//only a note, plz ignore this article if you do not need the information.
//for connection to mysql in linux with jsp
//Caution: I noticed that the word "string" can not work in jsp, "String" should be used!
//Set Privileges in Mysql, the host should be identified as "localhost.localdomain"
//prerequisite: Tomcat with JDBC driver, my system has been configured, so I skiped this step.
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost:3306/database";
//replace the "database"
Connection conn= DriverManager.getConnection(url,"username","passwd");
//replace the username and passwd
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from KEGG_ec";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
<%=rs.getString(1)%>
<%=rs.getString(2)%>
<%}%>
<%out.print("...........");%>
<%rs.close(); stmt.close(); conn.close(); %>
//you may need detailed knowledge from books about jsp!
Updating my Life
Subscribe to:
Post Comments (Atom)
1 comment:
N久没来了
留下爪印~~
Post a Comment