i have created program below ,but it does not run successfully why

import java.sql.*;


public class Bank {

   
    public static void main(String[] args) throws Exception {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        // TODO code application logic here
   try{
       Connection cn=DriverManager.getConnection("jdbc:odbc:rushiDSN");
       System.out.println("Connected Successfully");
       Statement stmt=cn.createStatement();
       stmt.executeUpdate("CREATE TABLE Author(AuID Number(3), AuName Char(15), AuAddr Char(30))");
       System.out.println("Table created successfully");
       stmt.close();
       cn.close();
   }catch(Exception e){System.out.println(e.getMessage());}
    }
}

it shows following error
error:
Connected Successfully
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in CREATE TABLE statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3109)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:287)
at Bank.main(Bank.java:16)

i have created program below ,but it does not run successfully why

import java.sql.*;


public class Bank {

   
    public static void main(String[] args) throws Exception {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        // TODO code application logic here
   try{
       Connection cn=DriverManager.getConnection("jdbc:odbc:rushiDSN");
       System.out.println("Connected Successfully");
       Statement stmt=cn.createStatement();
       stmt.executeUpdate("CREATE TABLE Author(AuID Number(3), AuName Char(15), AuAddr Char(30))");
       System.out.println("Table created successfully");
       stmt.close();
       cn.close();
   }catch(Exception e){System.out.println(e.getMessage());}
    }
}

it shows following error
error:
Connected Successfully
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in CREATE TABLE statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3109)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:287)
at Bank.main(Bank.java:16)

well there is definitely a syntax error in your SQL statement, though i cant see it:http://www.w3schools.com/sql/sql_create_table.asp make sure there is a space between "CREATE TABLE Author ()".

[edit] i think i found the main problem, there is no data type as "Number" in sql:http://www.w3schools.com/sql/sql_datatypes.asp

Edited 4 Years Ago by DavidKroukamp: n/a

This question has already been answered. Start a new discussion instead.