This blog would be providing you one stop solution for the clean solutions towards solving the problem, instead of just giving just instruction and not actual code.

13 Oct 2013

Plain JDBC connection to Oracle DB

No comments :
No talk, just the code.

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

/**
 * @author CK
 */
public class TestJDBCwithOracle {
 public static void main(String[] args) throws Exception {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn = DriverManager.getConnection("jdbc:oracle:10.128.69.124:1521:USDBTOT", "scott", "tiger");

  Statement stmt = conn.createStatement();
  ResultSet rset = stmt
    .executeQuery("select sysdate from dual");
  while (rset.next())
   System.out.println(rset.getString(1));
  rset.close();
  stmt.close();
  conn.close();
 }
}


No comments :

Post a Comment