标签:
1.注意属性为String的数据在JDBC操作语句中要加单引号
例子:
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/sounds","root", "root");
stmt = conn.createStatement();
并且UserId是varchar(100)类型。
错误:ResultSet rs = stmt.executeQuery("select * from userinfo where UserId = "+userid+");
正确:ResultSet rs = stmt.executeQuery("select * from userinfo where UserId = ‘"+userid+"‘");
标签:
原文地址:http://www.cnblogs.com/Deribs4/p/4886785.html