Source Code : Creating a table using JdbcOdbcDriver

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Creating a table using JdbcOdbcDriver

  
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class TableMaker {
  static String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";

  static String dbName = "Contacts";

  static String url = "jdbc:odbc:";

  static String SQLCreate = "CREATE TABLE CONTACT_INFO ("
      + "CONTACT_ID    INTEGER      NOT NULL   PRIMARY KEY,"
      + "ZIP           VARCHAR(10)  NOT NULL" + ");";

  public static void main(String[] args) throws Exception {
    Class.forName(jdbcDriver);
    url += dbName;
    Connection con = null;
    Statement stmt = null;
    con = DriverManager.getConnection(url);
    stmt = con.createStatement();
    stmt.execute(SQLCreate);
    con.close();
    if (con != null) {
      con.close();
    }
    if (stmt != null) {
      stmt.close();
    }

  }
}

   
  

Thank with us