java.sql.SQLSyntaxErrorException :: ORA-00907:缺少右括号错误

时间:2016-04-16 18:52:09

标签: java oracle

import java.sql.DriverManager;

import java.sql.Connection;

import java.sql.Statement;

public class Create

{

    public static void main( String [] args)throws Exception
    {
        Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522/orcl1","scott","sada");
        System.out.println("connection is createad");
        Statement stmt=con.createStatement();
        System.out.println("statemnt of object is createad");
        stmt.executeUpdate("create table iteam(iteamno number(3)primarykey,iteamname number(15),price number(4))");
        System.out.println("table is created ");
        con.close();
        stmt.close();
        System.out.println("conncetion closed");
    }
}

每件事都成功执行但在Statement对象之后,它会在程序执行时显示此错误:

  

java.sql.SQLSyntaxErrorException:ORA-00907:缺少右括号   错误

1 个答案:

答案 0 :(得分:1)

间距错误。固定在下面;在发布问题之前,你最好先在fiddle中试用你的陈述,@ sada:

import java.sql.DriverManager;

import java.sql.Connection;

import java.sql.Statement;

public class Create

{

    public static void main( String [] args)throws Exception
    {
        Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522/orcl1","scott","sada");
        System.out.println("connection is createad");
        Statement stmt=con.createStatement();
        System.out.println("statemnt of object is createad");
        stmt.executeUpdate("create table iteam(iteamno number(3) primary key,iteamname number(15),price number(4))");
        System.out.println("table is created ");
        con.close();
        stmt.close();
        System.out.println("conncetion closed");
    }
}