String userName="root"; //mysql用户名
String userPasswd="pwd"; //mysql密码
String dbName="database"; //使用的数据库名字
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;1
//mysql 下载connector
//拷贝到web服务器lib下
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn=DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
ResultSet out = stmt.executeQuery(sql);
form传递
request.setCharacterEncoding("gb2312");
地址栏直接传递
String str= new String(request.getParameter("val").getBytes("iso-8859-1"),"gb2312");