I have code of Connection class, where it gets a connection only from one database. Look at the DBConnection.java below
package eksim.db.sql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBConnection {
public Connection conn=null;
private static DBConnection dbConn=null;
static final String DB_URL=
"jdbc:sqlserver://10.0.0.47\\test;databaseName=a;";
static final String DB_USER="sa";
static final String DB_PASS="123";
public DBConnection(){
if(conn==null){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
conn=DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
public static DBConnection getInstance(){
DBConnection conn=null;
if(dbConn==null){
System.out.println("New");
dbConn=new DBConnection();
conn=dbConn;
} else{
conn=dbConn;
}
return conn;
}
public Connection getCon() throws SQLException{
return this.conn;
}
}
Now, i want to create another connection into the different database. Could anyone give me suggestion to modify this code in order to get the result of Connection into 2 database? thanks for any reply