Reputation: 39
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)
Upvotes: 0
Views: 571
Reputation: 17643
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 ")".
Upvotes: 1