0
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");
    }
}

Every thing executed successfully but after Statement object it will show this error when my program executes:

java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis Error

2
  • It's primary key not primarykey Commented Apr 16, 2016 at 19:03
  • I think you are missing some spaces before and after the word primary: create table iteam(iteamno number(3) primary key Commented Apr 16, 2016 at 19:03

1 Answer 1

1

A spacing error. Fixed below; you'd do well to try your statements in a fiddle before posting a question here, @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");
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.