MySQL connection URL issue [modified]
-
Connection con = DriverManager.getConnection("jdbc:odbc:employee");
please tell me that the methode of defining this
"jdbc:odbc:employee"
string. As mentioned ingetConnnection
detail in netbeans the first partjdbc
is fix and the second and the third issubProtocol
andsubName
... so tell me please what are these three things? I'm accessing MySQL databaseemployee.sql
using java servlet ... but i dont know this above mentioned statment mechanism so i m still failed to complete. I've also read some bloges/etc but cant ound detail that clear my queation. So plz me. Also plz tell me that in most of the examples and also in above given statment they defines database in two forms,"jdbc:mysql:employee"
or"jdbc:odbc://localhost/employee"
so what are these location on computer or on my local mechine so shere i keep database(employee.sql) to refer them like these two ways. THANKS TO ALL HELPERS ...modified on Wednesday, July 14, 2010 12:23 AM
-
Connection con = DriverManager.getConnection("jdbc:odbc:employee");
please tell me that the methode of defining this
"jdbc:odbc:employee"
string. As mentioned ingetConnnection
detail in netbeans the first partjdbc
is fix and the second and the third issubProtocol
andsubName
... so tell me please what are these three things? I'm accessing MySQL databaseemployee.sql
using java servlet ... but i dont know this above mentioned statment mechanism so i m still failed to complete. I've also read some bloges/etc but cant ound detail that clear my queation. So plz me. Also plz tell me that in most of the examples and also in above given statment they defines database in two forms,"jdbc:mysql:employee"
or"jdbc:odbc://localhost/employee"
so what are these location on computer or on my local mechine so shere i keep database(employee.sql) to refer them like these two ways. THANKS TO ALL HELPERS ...modified on Wednesday, July 14, 2010 12:23 AM
Hi, did you read this: http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1[^] Seems like a complete explanation of the mysql-jdbc-connectionstring issue. I suggest that you put your connection string into the config so that you can change it while running the site. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Hi, did you read this: http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1[^] Seems like a complete explanation of the mysql-jdbc-connectionstring issue. I suggest that you put your connection string into the config so that you can change it while running the site. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
Thanks .. But thing still creates problem to me. In this program they uses database
test
which is already exist ... where i dont know ..... but in case i create my own database then where i keep it and how to give database path in statmentcon = DriverManager.getConnection("jdbc:mysql:///test", "root", "secret");
package com.stardeveloper.example;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;public class JdbcExample2 {
public static void main(String args[]) {
Connection con = null;try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql:///test", "root", "secret"); if(!con.isClosed()) System.out.println("Successfully connected to " + "MySQL server using TCP/IP..."); } catch(Exception e) { System.err.println("Exception: " + e.getMessage()); } finally { try { if(con != null) con.close(); } catch(SQLException e) {} }
}
}