Home » Developer & Programmer » JDeveloper, Java & XML » JAVA connection to DATABASED
JAVA connection to DATABASED [message #554054] Thu, 10 May 2012 02:54
annu-agi
Messages: 193
Registered: July 2005
Location: Karachi
Senior Member

Dear Experts

see code the below and tell me what is this wrapper class do ? and how can i make connection class without use of wrapper. I just want to make class for making connection for database by passing parameters, parameter may not bound with any specific database it could be sqlserver, oracle or access. Would you please help me to make that kind of class?

regards

Anwer

//import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Wrapper;

public class DoConnect {

public Wrapper DoConnect(String drv, String url, String uid, String pss){
try {
Class.forName(drv);
System.out.println("Driver class found");
} catch (ClassNotFoundException err) {
System.out.println(err);
}
try {
System.out.println("Connected...");
return DriverManager.getConnection(url, uid, pss);
} catch (SQLException err) {
System.out.println(err);
}
return null;
}
public static void main(String[] args) {
DoConnect ocon= new DoConnect();
ocon.DoConnect("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@10.10.15.16:1521:lems", "scott", "tiger");
}

}
Previous Topic: XML Validation (merged 4)
Next Topic: teamwork
Goto Forum:
  


Current Time: Fri Apr 18 12:50:38 CDT 2014

Total time taken to generate the page: 0.09923 seconds