17 October 2012

jdbc connection with oracle 10 g

try{


String driverName = "oracle.jdbc.driver.OracleDriver";

Class.forName(driverName);



// Create a connection to the database

String serverName = "127.0.0.1";

String portNumber = "1521";

String sid = "xe";

String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + "/" + sid;

String username = "system";

String password = "9868626216";

Connection connection = DriverManager.getConnection(url, username, password);



String query="select * from employee";

Statement st= connection.createStatement();

ResultSet rs=st.executeQuery(query);

System.out.println(rs);

//while(rs.next())

//{



//System.out.println("not 1 empty");

//}











} catch (Exception e) {

// Could not find the database driver

e.printStackTrace();

}




Delicious add to del.icio.us saved by 0 users

No comments:

Post a Comment