ttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml">
中文测试页面
final String dbDriver = "com.mysql.jdbc.Driver" ;
final String dbUrl = "jdbc:mysql://localhost:3306/dbtest" ;
final String dbUser = "root" ;
final String dbPassword = "123456" ;
Connection conn ;
//PreparedStatement prepStmt ;
Statement stmt ;
%>
try {
Class.forName(dbDriver) ;
conn = DriverManager.getConnection(dbUrl,dbUser,dbPassword) ;
String sql = "insert into books(id,name) values('3','中国')" ;
stmt = conn.createStatement() ;
stmt.executeUpdate(sql) ;
//prepStmt = conn.prepareStatement(sql) ;
//prepStmt.setString(2,"这是一个中文测试") ;
//prepStmt.setString(3,"显示就表明测试正确") ;
//prepStmt.executeUpdate() ;
//prepStmt.close() ;
%>id
name
ResultSet rs = stmt.executeQuery("select * from books") ;
while(rs.next()) {
String id = rs.getString(1) ;
String name = rs.getString(2);
%>
}
%>
rs.close() ;
stmt.close() ;
conn.close() ;
}catch(Exception e) {
out.println("失败");
e.printStackTrace();
}
%>