Connection: createStatement() : Connection « java.sql « Java by API






Connection: createStatement()

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

public class Main {
  public static void main(String[] args) throws Exception {
    setup();
  }

  static Connection conn;

  static Statement st;

  public static void setup() {
    try {
      // Step 1: Load the JDBC driver.
      Class.forName("org.hsqldb.jdbcDriver");
      System.out.println("Driver Loaded.");
      // Step 2: Establish the connection to the database.
      String url = "jdbc:hsqldb:data/tutorial";

      conn = DriverManager.getConnection(url, "sa", "");
      System.out.println("Got Connection.");

      st = conn.createStatement();
    } catch (Exception e) {
      System.err.println("Got an exception! ");
      e.printStackTrace();
      System.exit(0);
    }
  }
}

           
         
    
  








JDBCEnvironment.zip( 595 k)

Related examples in the same category

1.Connection.TRANSACTION_NONE
2.Connection.TRANSACTION_READ_COMMITTED
3.Connection.TRANSACTION_READ_UNCOMMITTED
4.Connection.TRANSACTION_REPEATABLE_READ
5.Connection.TRANSACTION_SERIALIZABLE
6.Connection: close()
7.Connection: commit()
8.Connection: createStatement(int resultSetType, int resultSetConcurrency)
9.Connection: getAutoCommit()
10.Connection: getCatalog()
11.Connection: getMetaData()
12.Connection: getTransactionIsolation()
13.Connection: getWarnings()
14.Connection: nativeSQL(String sql)
15.Connection: prepareCall(String sql)
16.Connection: prepareStatement(String sql)
17.Connection: rollback()
18.Connection: rollback(Savepoint savepoint)
19.Connection: setAutoCommit(boolean autoCommit)
20.Connection: setSavepoint(String name)
21.Connection: setTransactionIsolation(int level)