在eclipse 中连接oracle,建表过程中出现 java.sql.SQLSyntaxErrorException: ORA-00904: : 标识符无效
这是源码:importjava.beans.Statement;importjava.sql.*;publicclassorclTest00{//定义与oracle的驱动...
这是源码:
import java.beans.Statement;
import java.sql.*;
public class orclTest00 {
//定义与oracle的驱动
public static final String DBDriver = "oracle.jdbc.driver.OracleDriver";
//定义oracle的数据库连接地址
public static final String DBUrl = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
//oracle数据库的连接用户名
public static final String DBUser = "scott";
//oracle数据库连接口令
public static final String DBPassW = "tiger";
public static void main(String args[]) throws Exception
{
Connection con =null;
String command = null;
java.sql.Statement stat = null;
try{
Class.forName(DBDriver);
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());//实例化驱动程序类
con = DriverManager.getConnection (DBUrl,DBUser,DBPassW); //@ip:端口号:数据库实例,用户名,密码
}
catch (SQLException e) {
e.printStackTrace();
}
try{
command = "create table student(number char(9),name char(8),sex char(2))";
stat = con.createStatement();
stat.executeUpdate(command);
System.out.println("表以建立");
}catch(Exception ex)
{
ex.printStackTrace();
}
}
}
这事它报的错:
java.sql.SQLSyntaxErrorException: ORA-00904: : 标识符无效
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:194)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1000)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1814)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1779)
at oracle.jdbc.driver.OracleStatementWrapper.executeUpdate(OracleStatementWrapper.java:277)
at orclTest00.main(orclTest00.java:30)
不知道该怎么办啊 展开
import java.beans.Statement;
import java.sql.*;
public class orclTest00 {
//定义与oracle的驱动
public static final String DBDriver = "oracle.jdbc.driver.OracleDriver";
//定义oracle的数据库连接地址
public static final String DBUrl = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
//oracle数据库的连接用户名
public static final String DBUser = "scott";
//oracle数据库连接口令
public static final String DBPassW = "tiger";
public static void main(String args[]) throws Exception
{
Connection con =null;
String command = null;
java.sql.Statement stat = null;
try{
Class.forName(DBDriver);
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());//实例化驱动程序类
con = DriverManager.getConnection (DBUrl,DBUser,DBPassW); //@ip:端口号:数据库实例,用户名,密码
}
catch (SQLException e) {
e.printStackTrace();
}
try{
command = "create table student(number char(9),name char(8),sex char(2))";
stat = con.createStatement();
stat.executeUpdate(command);
System.out.println("表以建立");
}catch(Exception ex)
{
ex.printStackTrace();
}
}
}
这事它报的错:
java.sql.SQLSyntaxErrorException: ORA-00904: : 标识符无效
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:194)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1000)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1814)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1779)
at oracle.jdbc.driver.OracleStatementWrapper.executeUpdate(OracleStatementWrapper.java:277)
at orclTest00.main(orclTest00.java:30)
不知道该怎么办啊 展开
展开全部
stat.executeUpdate(command)这个方法只能执行持久化操作,不能在数据库里建表
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建表语句"create table student(number char(9),name char(8),sex char(2))";中number为oracle关键字,不能作为字段名称。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
直接备份导出
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询