score:0

Accepted answer

username and password needs to be passed to the getconnection() eg.

connection conn = null; 
 string url = "jdbc:mysql://localhost/"; 
 string dbname = "somedb"; 
 string driver = "com.mysql.jdbc.driver"; 
 string username = "root"; string password = "password"; 
 try { class.forname(driver).newinstance();
       conn = drivermanager.getconnection(url+dbname,username,password);   system.out.println("connected to the database"); conn.close(); system.out.println("disconnected from database"); } catch (exception e) { system.out.println("no connection =("); } }

Related Query

More Query from same tag