The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

You should do your home work too !

Posted by Senthoor on December 09, 2001 at 7:43 AM

import java.sql.*;
import java.math.*;
import java.io.*;

class dbAccessThin {
public static void main (String args []) throws SQLException
{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@venus:1526:db15", "scott", "tiger");
// @machineName:port:SID, userid, password

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

Hope this small code helps you to establish the connection.In order to get the connection these two lines of codes are enough...

DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection();

Moreover before posting a question to any forum please do your home work and search the web.... Don't be lazy :-)

STFW STFW STFW STFW STFW

Don't ask me what is STFW :-)




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us