Я пытаюсь создать таблицу в базе данных Oracle с помощью следующего кода Java:
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());
}
}
}
Я получаю следующую ошибку:
Попытка подключения ...
связное!
SQLException: Io исключения: несоответствие размера блока данных (SDU)
СТРОИТЬ УСПЕШНО (общее время: 2 секунды)