這個作品在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