Re: Creating a DataSource
Re: Creating a DataSource
Which database is being used by you???
If you have given the .jar files correctly then now you have to give some details to connect with database like:
String DRIVER_NAME = "com.mysql.jdbc.Driver"; // for mysql db
String DB_URL = "jdbc:mysql://localhost:3306/database_name"; //3306 is port number
String USERID= "root"; //root is default username
String PASSWORD = "root"; //root is default password
private Connection getConnection() throws ClassNotFoundException, SQLException
{
// Step -1 Load the Database Driver
Class.forName(DRIVER_NAME);
// Step -2 Create Connection
Connection con = DriverManager.getConnection(DB_URL,USERID,PASSWORD);
return con;
}
For other databases (other than MySql) search the drivers name and port number your self.