不能通过Java使用ojdbc在Oracle数据库上创建表



我试图通过以下Java代码在Oracle数据库上创建一个表:

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异常:Size Data Unit (SDU) mismatch
构建成功(总时间:2秒)

语句:

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)

需要一个")"

相关内容

  • 没有找到相关文章

最新更新