level 1
一滩死水
楼主
为什么用jsp连接mysql的时候.插入数据或者读取里面的数据都是乱码啊.特别是插入的时候.如下代码:<%@ page contentType="text/html;charset=gb2312"%><%@ page import="java.sql.*"%><%request.setCharacterEncoding("gb2312");%><% String DRIVER="com.mysql.jdbc.Driver"; String DBURL="jdbc:mysql://localhost/bdifn?user=root&password=1234"; Connection conn =null; Statement stmt=null; try {Class.forName("com.mysql.jdbc.Driver");} catch (ClassNotFoundException e) { out.println("class not found!!");}try{ conn=DriverManager.getConnection(DBURL); stmt=conn.createStatement(); stmt.executeUpdate("insert into note values(null,'你好啊','好啊','乱七八糟的啊~')");}catch(Exception e){ e.printStackTrace();}finally{try{ if(stmt!=null){ stmt.close(); stmt=null; } if(conn!=null){ conn.close(); conn=null; } }catch(Exception e) { e.printStackTrace(); }}%>
2007年03月29日 12点03分
1