Java使用mySql写入数据是出现的问题,字符集我已经调为一样的,都是UTF_8,但还是有问题,代码如下:
Stringurl="jdbc:mysql://localhost/mysql";Stringuser="ghl";Stringpwd="ghl13";Class.for...
String url="jdbc:mysql://localhost/mysql";
String user="ghl";
String pwd="ghl13";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(url,user, pwd);
Statement stmt = conn.createStatement();//��������������ִ��sql����
String createTableTeam = "CREATE TABLE teambaseinfo " +
"(fullName VARCHAR(32),teamAbb VARCHAR(32),location VARCHAR(32)," +
"division VARCHAR(32),partition VARCHAR(32),homeGround VARCHAR(32),formedTime VARCHAR(32))";
stmt.executeUpdate(createTableTeam);//以上几行是连接数据库并建立表格,运行到这之前都是没有问题的
sqrStr="inser into o(fullName,teamAbb,location,division,partition,homeGround,formedTime) values('Hawks','ATL','Atlanta','E','H','Philips Arena','1949')";
stmt.executeUpdate(sqrStr); //这里就出现了问题,报错信息如下,希望懂的朋友可以帮帮忙,我给的积分不会少的。
Error : com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'partition VARCHAR(32),homeGround VARCHAR(32),formedTime VARCHAR(32))' at line 1
补充一下问题:
sqrStr="inser into o(fullName,teamAbb,location,division,partition,homeGround,formedTime) values('Hawks','ATL','Atlanta','E','H','Philips Arena','1949')";
stmt.executeUpdate(sqrStr);
上面这段代码,insert into o,应该改为teambaseinfo,我手误了,错误不是这个地方 展开
String user="ghl";
String pwd="ghl13";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(url,user, pwd);
Statement stmt = conn.createStatement();//��������������ִ��sql����
String createTableTeam = "CREATE TABLE teambaseinfo " +
"(fullName VARCHAR(32),teamAbb VARCHAR(32),location VARCHAR(32)," +
"division VARCHAR(32),partition VARCHAR(32),homeGround VARCHAR(32),formedTime VARCHAR(32))";
stmt.executeUpdate(createTableTeam);//以上几行是连接数据库并建立表格,运行到这之前都是没有问题的
sqrStr="inser into o(fullName,teamAbb,location,division,partition,homeGround,formedTime) values('Hawks','ATL','Atlanta','E','H','Philips Arena','1949')";
stmt.executeUpdate(sqrStr); //这里就出现了问题,报错信息如下,希望懂的朋友可以帮帮忙,我给的积分不会少的。
Error : com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'partition VARCHAR(32),homeGround VARCHAR(32),formedTime VARCHAR(32))' at line 1
补充一下问题:
sqrStr="inser into o(fullName,teamAbb,location,division,partition,homeGround,formedTime) values('Hawks','ATL','Atlanta','E','H','Philips Arena','1949')";
stmt.executeUpdate(sqrStr);
上面这段代码,insert into o,应该改为teambaseinfo,我手误了,错误不是这个地方 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询