Hi, I’m working on the project in JAVA and I’ve got a problem with connection to database. My Database (in sql) is located on bplaced.net. This is a fragment of my java’s code:
String url = “jdbc:sql:projektanty.bplaced.net/mysql”;//mysql is a name of my database
String username = “projektanty”;
String password = “******”;
Statement s = null;
Connection c = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (Exception e) {
System.err.println("Error loading JDBC/ODBC.");
}
try {
c = DriverManager.getConnection (url, username, password);//the problem is with URL, I think...
s = c.createStatement();
} catch (Exception e) {
System.err.println("cannot connect to "+url);
}
}
Try to use ‘localhost’ instead of ‘url’ and make sure that your database-name [quote]String url = “jdbc:sql:projektanty.bplaced.net/mysql”;//mysql is a name of my database[/quote] is the same like your username. Your database can’t be named “mysql” - it is “projektanty” or even start with projektanty.
when I changed part of my code :
try {
c = DriverManager.getConnection (url, username, password);
s = c.createStatement();
} catch (Exception e) {
System.err.println(“There’s a problem with connection to " + url+”\n"+e);// there’s a change (+e)
}
There’s a problem with connection to jdbc:odbc://localhost/byczabaza
java.sql.SQLException: [Microsoft][Driver Manager ODBC] Cannot find a name of data source and there’s no default driver.
It can mean that I should configure something in Control Panel… but how to ?