时间:2021-07-01 10:21:17 帮助过:2人阅读
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+"‘");
关于Mysql数据库的注意点
标签: