Ich habe da ein echtes Problem.... und das seit Tagen :/...
ich mache eine MySQL Abfrage und bekomme natürlich X Zeilen zurück... für jede will ich alle Werte im String speichern... wie erstelle ich nun ein Array das genau X groß ist ??
Das ist mein Momentaner Quellcode:
und die MySQL Connection_n:
ich mache eine MySQL Abfrage und bekomme natürlich X Zeilen zurück... für jede will ich alle Werte im String speichern... wie erstelle ich nun ein Array das genau X groß ist ??
Das ist mein Momentaner Quellcode:
Java:
public static void main(String[] args)
{
conn = getInstance();
if(conn != null)
{
// Anfrage-Statement erzeugen.
Statement query = null;
ResultSet result = null;
try
{
query = conn.createStatement();
String sql = "SELECT * FROM bot_grundeinstellung;";
result = query.executeQuery(sql);
MySQLConnection_n Connection2 = new MySQLConnection_n();
// Ergebnissätze durchfahren.
while (result.next())
{
Connection2.Connection(result);
}
showMessageDialog(null, Connection2.getBot_Key());
} catch (SQLException e) {
// Es ist ein Fehler passiert
//e.printStackTrace();
} finally {
try { if (result != null) result.close(); } catch (Exception e) {};
try { if (query != null) query.close(); } catch (Exception e) {};
try { if (conn != null) conn.close(); } catch (Exception e) {};
}
}
}
und die MySQL Connection_n:
Java:
public class MySQLConnection_n
{
private String ip = "";
private String serverid = "";
private String name = "";
private String bot_key = "";
private String username = "";
private String password = "";
private String queryport = "";
private String active = "";
public void Connection(ResultSet result) throws SQLException
{
ip = result.getString("ip_adress");
serverid = result.getString("serverid");
name = result.getString("serverid");
bot_key = result.getString("serverid");
username = result.getString("serverid");
password = result.getString("serverid");
queryport = result.getString("serverid");
active = result.getString("serverid");
}
public String getIp()
{
return ip;
}
public String getServerId()
{
return serverid;
}
public String getName()
{
return name;
}
public String getBot_Key()
{
return bot_key;
}
public String getUsername()
{
return username;
}
public String getPassword()
{
return password;
}
public String getQueryPort()
{
return queryport;
}
public boolean getActive()
{
if(active.equals("true"))
{
return true;
}
else
{
return false;
}
}
}