JDBC getConnection
843859Aug 6 2007 — edited Aug 16 2007hi,
from some time I try to get a connection with a database for a standalone program on my computer using JDBC but I am not able to finish my purpose... and I am looking for for some help.
I had a connection to an Microsoft access database with the ODBC bridge but I never could get connection by any driver of JDBC.
I tried with some products but recently I am using Interbas of Borland.
I am using a Windows XP Oprating System.
I wite the follow code:
static public Connection makeDataBaseConnectionWithInterbase(){
Connection dbconn = null;
String url = "jdbc:interbase://localhost/G:\\Java\\employee.gdb";
// String url = "jdbc:interbase://ZORRO/G:/Java/employee.gdb";
// String url = "jdbc:interbase://loopback/G:/Java/employee.gdb";
try {
Class.forName("interbase.interclient.Driver");
} catch ( ClassNotFoundException cnfex ) {
// cnfex.printStackTrace();
System.out.println("getCause = " + cnfex.getCause());
System.out.println("getMessage = " + cnfex.getMessage());
}
try {
Driver driver = DriverManager.getDriver(url);
System.out.println("driver = " + driver.toString());
dbconn = DriverManager.getConnection(url,"sysdba","masterkey");
} catch ( SQLException cnfex ) {
cnfex.printStackTrace();
System.out.println("Eccezione getCause = " + cnfex.getCause());
}
return dbconn ;
}
--------------
I give the classpath to interbase driver by command line writing:
path.. java -cp pathInterbase\interclient.jar; myProgram(.class)
I know the name of the driver with this line of output:
driver = interbase.interclient.Driver@b8df17
But after this I get a message indicating that the connection failed and that is the message:
java.sql.SQLException: interbase.interclient.IBException: [interclient][interbas
e]Unable to complete network request to host "java.net.ConnectException: Connect
ion refused: connect".
I hope someone could help me...
Thank you tonyMrsangelo