public static void InMySQL(String[][] args, String unischrift){
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e){
System.out.println("Kann nicht geladen werden");
return;
}
try{
Connection con=
DriverManager.getConnection(
"jdbc:mysql://localhost/bib");
Statement stmt=(Statement) con.createStatement();
String bef;
/\*String autor="Kant";
String titel="Kritik der reinen Vernunft";
int jahr=1965;\*/
bef="insert into " + unischrift
+"(CustomID, Bisheriger Nutzen , Zeitraum) "
+"values (\""+args[0][0]+"\", \""+args[0][1]+"\", \""+null+"\")";
//System.out.println(bef);
ResultSet rs=stmt.executeQuery(bef);
rs.close();
stmt.close();
con.close();
}
catch (SQLException se){
System.out.println("SQL Fehler "+se.getMessage());
se.printStackTrace(System.out);
}
}
ich benutze diese methode um die tabelle zbiscgrift der datenbank Customer zu füllen, bekomme aber diese exception:
SQL Fehler Access denied for user ''@'localhost' (using password: NO)
java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at GUI.Main.InMySQL(Main.java:57)
at GUI.Main.main(Main.java:39)
hm, muss ich da jetzt irgendein passwort angeben?