FileDocCategorySizeDatePackage
TestInstallCreateTable.javaAPI DocExample1338Fri Oct 01 15:08:04 BST 1999None

TestInstallCreateTable

public class TestInstallCreateTable extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    Connection conn=null;;
    PreparedStatement ps=null;

    /* if you're using a non-Oracle JDBC Driver, add a call here to
	DriverManager.registerDriver() to register your Driver
    */

    // set the default connection to the URL, user, and password
    // specified in your connect.properties file
    Oracle.connect(TestInstallCreateTable.class, "connect.properties");

    conn = DefaultContext.getDefaultContext().getConnection();

    try {
      ps = conn.prepareStatement("DROP TABLE SALES");
      ps.executeUpdate();
    } catch (SQLException e) {
      // it'll throw an error of the table doesn't exist in many JDBC drivers
	;
    }

    try {
      ps = conn.prepareStatement(
	"CREATE TABLE SALES (" +
		"ITEM_NUMBER NUMBER, " +
		"ITEM_NAME CHAR(30), " +
		"SALES_DATE DATE, " +
		"COST NUMBER, " +
		"SALES_REP_NUMBER NUMBER, " +
		"SALES_REP_NAME CHAR(20))");

      ps.executeUpdate();

      System.out.println("SALES table created");
    } catch (SQLException se) {
	System.out.println("oops! can't create the sales table.  error is:");
	se.printStackTrace();
    }