0

I am trying to create a table on an Oracle database through following Java code:

import java.io.PrintStream;
import java.sql.*;

public class TestJDBC
{

public TestJDBC()
{
}

public static void main(String args[])
{
    //String s = "Create table phone(fullname VARCHAR(30) NOT NULL,phnumber VARCHAR(30) NOT NULL)";
    //String s1 = "INSERT INTO phone VALUES ('Ted Nicholson', '201 555-1212')";
    //String s2 = "SELECT * FROM phone";
    try
    {
        Class.forName("oracle.jdbc.driver.OracleDriver");
    }
    catch(ClassNotFoundException classnotfoundexception)
    {
        System.err.print("ClassNotFoundException: ");
        System.err.println(classnotfoundexception.getMessage());
    }
    try
    {
        System.out.println("Trying to connect...");
        Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@prophet.njit.edu:1521:course", "k45", "XXXX");
        System.out.println("connected!");
        Statement statement = connection.createStatement();
        statement.executeUpdate("Create table addressbook(first VARCHAR(30) NOT NULL, last VARCHAR(30) NOT NULL, address VARCHAR(30) NOT NULL, phone VARCHAR(15), email VARCHAR(30), dob  date, Sex char(10)");
        //statement.executeUpdate(s);
        System.out.println("Created Table.");
        //statement.executeUpdate("INSERT INTO phone VALUES('Ted Nicholson', '201 555-1212'");
        //System.out.println("Inserted one record.");
        //String s3;
        //for(ResultSet resultset = statement.executeQuery(s2); resultset.next(); System.out.println(s3))
            //s3 = (new StringBuilder()).append(resultset.getString(1)).append(" ").append(resultset.getString(2)).toString();

        statement.close();
        connection.close();
    }
    catch(SQLException sqlexception)
    {
        System.err.print("SQLException: ");
        System.err.println(sqlexception.getMessage());
    }
}

}

I get following error:

Trying to connect...
connected!
SQLException: Io exception: Size Data Unit (SDU) mismatch
BUILD SUCCESSFUL (total time: 2 seconds)

1
  • try to run that create table query manually via SQL Developer Commented Dec 15, 2011 at 10:36

1 Answer 1

1

This statement:

Create table addressbook(first VARCHAR(30) NOT NULL, last VARCHAR(30) NOT NULL, address VARCHAR(30) NOT NULL, phone VARCHAR(15), email VARCHAR(30), dob  date, Sex char(10)

needs a ")".

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.