JSP and MySQL connection
######################################################################################################################################################################################################################################################################################################## ################################
Chinese problem:
When JSP and MySQL are connected, you must add:
<% @ Page ContentType = "Text / HTML; Charset = GB2312"%>
If you are the form of your form, you should add:
JDBC: mysql: //127.0.0.1: 3306 / Publish? useunicode = true & characterencoding = GBK "and
<% Request.SetCharacterencoding ("GBK");%>
######################################################################################################################################################################################################################################################################################################## ###################
1.
<% @ Page ContentType = "Text / HTML; Charset = GB2312"%>
<% java.sql.connection sqlconn; java.sql.Statement SQLSTMT; java.sql.resultset Sqlrst; // Regiester JDBC Driver
String dbuser = "root"; string dbpassword = "root"; string dbserver = "127.0.0.1"; // can't use localhost, you must use ip or cname string dbname = "publish"; // change to your db Name
Class.Forname ("org.gjt.mm.mysql.driver"). NewInstance (); // connect to the database sqlconn = java.sql.driverManager.getConnection ("JDBC: mysql: //" DBSERVER ": 3306 / " DBNAME "? Useunicode = true & characterencoding = GB2312 ",
Dbuser, dbpassword; // create the driver handle sqlstmt = sqlconn.createstatement
(Java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY); // excute sql sqlRst = sqlStmt.executeQuery ( "select * from book");%>