当前页面: 开发资料首页 → J2SE 专题 → 一个mysql的基本问题,请指点,谢谢!
一个mysql的基本问题,请指点,谢谢!
摘要: 一个mysql的基本问题,请指点,谢谢!
我想通过java代码在数据库中创建一个表,写了下面的代码:
String testSql = -#34;CREATE TABLE `test1`(`id` int(11) NOT NULL auto_increment `filed1` varchar(11) default NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=gb2312-#34;;
ResultSet rs = statement.executeQuery(testSql); //statement已经创建好
执行的时候报java.sql.SQLException: Can not issue data manipulation statements with executeQuery().,请问要在代码中创建表该怎么做,谢谢!
sql好像没有-#39; 只有-#34;
用
statement.executeUpdate(testSql);
executeQuery是执行查询的,没有写的权限,用update试试
up