【发布时间】:2012-07-25 07:30:08
【问题描述】:
这适用于 MySql-
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()一个查询 -
@shubhansh - execute() 也失败了。同样的错误。