Expand|Select|Wrap|Line Numbers
- import java.sql.*;
- public class connect
- {
- public static void main (String[] args)
- {
- Connection conn = null;
- try
- {
- String userName = "myname";
- String password = "mypassword";
- String url = "jdbc:mysql:localhost";
- Class.forName ("com.mysql.jdbc.Driver").newInstance ();
- conn = DriverManager.getConnection (url, userName, password);
- System.out.println ("Database connection established");
- }
- catch (Exception e)
- {
- System.err.println ("Cannot connect to database server");
- }
- finally
- {
- if (conn != null)
- {
- try
- {
- conn.close ();
- System.out.println ("Database connection terminated");
- }
- catch (Exception e) { /* ignore close errors */ }
- }
- }
- }
- }
what i cant figure out is what to assign to the "url" variable.. in other words .. how shall i determine the url of the company mysql server ? every time i run this code i get the same error "Cannot connect to database server".
I am using debian linux OS
any help appreciated,
regards
rhitam.