有大神帮我看一下出了什么问题吗?
Statement st = null;
st = con.createStatement();
st.executeQuery(create table op(
name char(4) not null,
rank char(3) not null,
primary key(name) );
);
st.executeQuery后面的东西是字符串,必须加上引号写在一行。
字符串加双引号:例如
String sql = "select * from tablename";
Connection con = null;
Statement st = null;
con = DBO.getConnection();//自己写的一个数据库连接的类,有getConnection()连接方法
//下面这两句要抛异常的try{}catch(Exception e){e.printStrackpace();}
st = con.createStatement();
rs = st.executeQuery(sql);
需要字符串类型的参数
String sql="****";
st.executeQuery(sql);