-1
<%@ page language="java" import="java.sql.*"%>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
out.println(username+password); //just for checking
Connection conn = null;
ResultSet rst=null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "olts";
String driver = "com.mysql.jdbc.Driver";
String userName1 = "root";
String password1 = "root";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName1,password1);
out.println("Connected to the database");
Statement stmt=null;
stmt=conn.createStatement();
String qry = "select * from users where username='" + username +"' and password='"+password + "'";
rst=stmt.executeQuery(qry);
out.println(qry);
conn.close();
out.println("Disconnected from database");
} catch(Exception e) {
e.printStackTrace();
}
%>
同時運行它,越來越沒有數據庫連接的語句作爲輸出也沒有任何exceptions..any print語句執行相關的陳述之前,如果我們把任何聲明數據庫連接後,它不工作.. 即時通訊使用MySQL數據庫,並已將連接器jar文件放在tomcat6/lib ... 請幫我...問題JDBC同時使用的tomcat6