Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

MySQL jdbc driver

$
0
0
Hi everyone,

I have a problem that is driving me crazy, im really not used to working with mySQL databases and i really need some help with this. I want to connect to my MySQL database to run querys and eventually be able to load data in to the database and measure the time consumed for loading, querying etc, so i can compare the performance on different kinds of databases.
I THINK i got the forName to work, but now its complaining about the dbUrl.
Can someone explain to me what im doing wrong?

Thanks in advance!



import java.sql.*;
import java.util.Properties;

import javax.sql.*;


public class jdbcdemo{

public static void main(String args[]){
String dbtime;
String dbUrl = "jdbc:mysql://localhost:3306/Meeting";
String dbClass = "com.mysql.jdbc.Driver";
String query = "Select * FROM customer";

Properties properties = new Properties();
properties.put("user", "student");
properties.put("password", "ingan86");

try {

Class.forName("com.mysql.jdbc.Driver"); 
Connection con = DriverManager.getConnection (dbUrl,properties);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {
dbtime = rs.getString(1);
System.out.println(dbtime);
} 

con.close();
} 
catch(SQLException e) {
e.printStackTrace();
}

catch(Exception e) {
e.printStackTrace();
}


} 

}  



java.sql.SQLException: Access denied for user 'student'@'localhost' (using password: YES)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:798)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3700)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1203)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2572)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at jdbcdemo.main(jdbcdemo.java:22)

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>