Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package DB;
- /**
- *
- * @author microcosm
- */
- import java.sql.Connection;
- import java.sql.DriverManager;
- /*
- * DatabBase.java
- *
- * Created on August 30, 2007, 5:19 PM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
- /**
- *
- * @author ganesheway
- */
- public class DataSources {
- static String username = "tms";
- static String password = "tms";
- public static Connection getOracleConnection() {
- String driver = "oracle.jdbc.OracleDriver";
- String url = "jdbc:oracle:thin:@localhost:1521:XE";
- try {
- Class.forName(driver); // load Oracle driver
- Connection conn = DriverManager.getConnection(url, username, password);
- return conn;
- } catch (Exception ex) {
- ex.printStackTrace();
- } // load Oracle driver
- return null;
- }
- public static void main(String args[])throws Exception{
- DataSources db = new DataSources();
- Connection con = db.getOracleConnection();
- if(con==null){
- System.out.println("connection not established");
- }
- else{
- System.out.println("connection established");
- }
- }
- }
Add Comment
Please, Sign In to add comment