i need a sample code regarding oracle thin driver in ejb

Discussions

EJB programming & troubleshooting: i need a sample code regarding oracle thin driver in ejb

  1. hi ,
          i am using oracle jdbc thin driver.could u please send a sample code for connecting to database and querying to database.in this i am using connection pooling .if u want my pgms i will send to u.

    please give ur reply asap

    advance thanks

    hima
  2. You can define an DataSource object in your deployment descriptor (if using EJB). It new in JDBC 2 and the auto pooling.

    Or if you want the code which use Thin driver:

    try {
       Class.forName("oracle.jdbc.driver.OracleDriver");
       Connection con=DriverManager.getConnection(
    "oracle:jdbc:thin:@sereverName:port:service");
    //port: default is 1521
    Statement stmt=con.createStatement();
    ResultSet rs.stmt.executeQuery(query);
    }
    Catch(. . .) {
    }

    hope this will help
  3. try {
       Class.forName("oracle.jdbc.driver.OracleDriver");
       Connection con=DriverManager.getConnection(
    "oracle:jdbc:thin:userid/password@host:port:datasource");
    //port: default is 1521
    Statement stmt=con.createStatement();
    ResultSet rs.stmt.executeQuery(query);
    }
    Catch(ClassNotFounderException. . .) {
    }

    Catch(SQLException. . .) {
    }