Okay. So weit, so gut.
Das mit dem "this" hat etwas gebracht. Ich bekomme jetzt nicht mehr die Meldung mit "URL cannot be null".
Anstatt dessen kommt jetzt folgende Meldung:
[CODE]
15:24:16 [SEVERE] java.sql.SQLException: Access denied for user 'carpetsql9'@'95
.119.57.234' (using password: YES)
15:24:16 [SEVERE] at com.mysql.jdbc.SQLError.createSQLException(SQLError.j
ava:1073)
15:24:16 [SEVERE] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
3593)
15:24:16 [SEVERE] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
3525)
15:24:16 [SEVERE] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
931)
15:24:16 [SEVERE] at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:403
1)
15:24:16 [SEVERE] at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1296)
15:24:16 [SEVERE] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionI
mpl.java:2338)
15:24:16 [SEVERE] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Conne
ctionImpl.java:2371)
15:24:16 [SEVERE] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionI
mpl.java:2163)
15:24:16 [SEVERE] at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.j
ava:794)
15:24:16 [SEVERE] at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection
.java:47)
15:24:16 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance
0(Native Method)
15:24:16 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance
(Unknown Source)
15:24:16 [SEVERE] at sun.reflect.DelegatingConstructorAccessorImpl.newInst
ance(Unknown Source)
15:24:16 [SEVERE] at java.lang.reflect.Constructor.newInstance(Unknown Sou
rce)
15:24:16 [SEVERE] at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
15:24:16 [SEVERE] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionI
mpl.java:378)
15:24:16 [SEVERE] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegist
eringDriver.java:305)
15:24:16 [SEVERE] at java.sql.DriverManager.getConnection(Unknown Source)
15:24:16 [SEVERE] at java.sql.DriverManager.getConnection(Unknown Source)
15:24:16 [SEVERE] at de.mrpixeldream.mysqlreader.SQLConnector.connect(SQLC
onnector.java:101)
15:24:16 [SEVERE] at de.mrpixeldream.mysqlreader.HandlerTask.run(HandlerTa
sk.java:41)
15:24:16 [SEVERE] at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftT
ask.java:53)
15:24:16 [SEVERE] at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainT
hreadHeartbeat(CraftScheduler.java:345)
15:24:16 [SEVERE] at net.minecraft.server.MinecraftServer.q(MinecraftServe
r.java:510)
15:24:16 [SEVERE] at net.minecraft.server.DedicatedServer.q(DedicatedServe
r.java:213)
15:24:16 [SEVERE] at net.minecraft.server.MinecraftServer.p(MinecraftServe
r.java:474)
15:24:16 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftSer
ver.java:406)
15:24:16 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(Sour
ceFile:539)
[/CODE]
Wobei auch hier der erste Eindruck täuscht. Ich greife NICHT mit falschem User oder Passwort auf den Server zu sondern die MySQL-Klasse führt anscheinend einen Fallback auf den eigenen Rechner durch. Die IP, auf die er sich oben verbinden möchte ist die, die mir Wie ist meine IP-Adresse? für meinen lokalen Rechner ausgibt. Er löst also die übergebene URL "mrpixeldream.de" falsch oder gar nicht auf.
Mein jetziger MySQL-Code:
[code=Java]
package de.mrpixeldream.mysqlreader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SQLConnector
{
private boolean isInitialized;
private boolean isConnected;
private boolean isFailed;
private String server;
private String user;
private String password;
private String database;
private Connection con;
private Statement stmt;
private ResultSet result;
public SQLConnector()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e)
{
// TODO Automatisch generierter Erfassungsblock
e.printStackTrace();
}
isInitialized = false;
isConnected = false;
isFailed = false;
}
public SQLConnector(String server, String user, String password, String database)
{
isInitialized = true;
isConnected = false;
this.user = user;
this.password = password;
this.database = database;
if (!server.startsWith("jdbc:mysql://"))
{
server = ( "jdbc:mysql://" + server + "/" + database);
}
this.server = server;
try
{
con = DriverManager.getConnection(server, user, password);
}
catch (SQLException e)
{
e.printStackTrace();
if (e.getMessage().contains("denied"))
{
System.err.println("[MySQL-Reader] CAN'T CONNECT! WRONG USER AND/OR PASSWORD!");
isFailed = true;
return;
}
return;
}
try
{
stmt = con.createStatement();
}
catch (SQLException e)
{
e.printStackTrace();
System.err.println("[MySQL-Reader] AN UNKNOWN ERROR OCCURRED!");
isFailed = true;
return;
}
isFailed = false;
isConnected = true;
return;
}
public boolean connect()
{
if (isConnected || isFailed || !isInitialized)
{
return false;
}
else
{
try
{
con = DriverManager.getConnection(server, user, password);
}
catch (SQLException e)
{
e.printStackTrace();
if (e.getMessage().contains("denied"))
{
System.err.println("[MySQL-Reader] CAN'T CONNECT! WRONG USER AND/OR PASSWORD!");
isFailed = true;
return false;
}
if (e.getMessage().contains("refused"))
{
System.err.println("[MySQL-Reader] CAN'T CONNECT! SERVER NOT AVAILABLE!");
isFailed = true;
return false;
}
return false;
}
return true;
}
}
public boolean disconnect()
{
if (!isConnected || isFailed || !isInitialized)
{
return false;
}
else
{
try
{
con.close();
}
catch (SQLException e)
{
e.printStackTrace();
System.err.println("[MySQL-Reader] CAN'T CLOSE CONNECTION!");
e.printStackTrace();
return false;
}
con = null;
return true;
}
}
public void init(String server, String user, String password, String database)
{
isInitialized = true;
isConnected = false;
this.user = user;
this.password = password;
this.database = database;
if (!server.startsWith("jdbc:mysql://"))
{
server = ( "jdbc:mysql://" + server + "/" + database);
}
this.server = server;
}
public ResultSet query(String sql_query)
{
if (!isInitialized || isFailed || !isConnected)
{
System.err.println("[MySQL-Reader] NO CONNECTION FOUND!");
System.err.println("[MySQL-Reader] Fail: " + isFailed);
System.err.println("[MySQL-Reader] Connection: " + isConnected);
System.err.println("[MySQL-Reader] Init: " + isInitialized);
return null;
}
try
{
stmt = con.createStatement();
}
catch (SQLException e1)
{
e1.printStackTrace();
}
try
{
return this.stmt.executeQuery(sql_query);
}
catch (SQLException e)
{
System.err.println("[MySQL-Reader] CAN'T EXECUTE QUERY! ERROR:");
e.printStackTrace();
return null;
}
}
}
[/code]
Ich würde mich sehr freuen, wenn wir auch dieses Problem lösen könnten 