这个作品在MySql-创建表工作在MySQL,但不是在JDBC
create database CarRentalCo;
use CarRentalCo;
create table LuxuryCars(rate varchar(5));
我试着做在Java中同样的事情,使用JDBC和我得到了一个错误 -
//Some code here
String query =
"create database CarRentalCo; "
"use CarRentalCo; "
"create table LuxuryCars(rate varchar(5)); "
//some code here
executeUpdate(query);
错误:
com.mysql.jdbc.exceptions.jdbc4.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 'use CarRentalCo; create table LuxuryCars(rate varchar(5))' at line 1
每执行一个查询executeUpdate()' – 2012-07-25 07:32:15
尝试使用execute() – Shubhansh 2012-07-25 07:38:14
@shubhansh - execute()也会失败。同样的错误。 – 2012-07-25 07:40:10