package jdbctest;
import java.sql.*;
public class TestConnection {
public TestConnection() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Oracle JDBC driver is loaded .");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:cric/buzz@seatsrvr:1521:orcl");
System.out.println("Connection is established to seatsvr:1521 with user=cric password=buzz tns connection string being orcl.");
DatabaseMetaData dm = conn.getMetaData();
System.out.println("Major Version= " + dm.getDatabaseMajorVersion() +
" Minor Version= " + dm.getDatabaseMinorVersion() +
" Product Name= " + dm.getDatabaseProductName());
System.out.println("Printed the Driver Information!");
}
catch(Exception e) {
System.out.println("Exception"+ e);
}
}
public static void main(String[] args)
{
TestConnection t = new TestConnection();
}
}
Start Learning JDBC Programming here
use this also
No comments:
Post a Comment