jemand ne idee, warum er mir die daten nich schreiben kann?
vielen dank im voraus für die hilfe!
Code:
import java.sql.*;
import java.net.*;
import java.awt.event.*;
import java.lang.*;
import java.awt.*;
import javax.swing.*;
public class WeatherWrite{
private String conn_Output;
private String dbHost = "localhost";
private String dbPort = "3306";
private String dbName = "root";
private String user = "admin";
private String passwd = "root";
private Connection conn = null;
private Statement statement;
static public String dateVar, mysqlStatement;
static public double tempVar, preVar, windVar, lightVar, airVar;
static int directVar;
public WeatherWrite() {
initDB();
}
public void initDB(){
//treiber laden
String driver = "com.mysql.jdbc.Driver";
try
{
Class.forName(driver).newInstance();
}
catch (Exception e)
{
//System.out.println("Treiber nicht geladen!");
//e.printStackTrace();
}
//verbindung herstellen
try
{
conn = DriverManager.getConnection("jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbName , user , passwd);
}
catch(SQLException sqle)
{
conn_Output = "jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbName + ","+ user+ ","+ passwd;
//System.out.println(conn_Output);
//System.err.println("Error message: " + sqle.getMessage());
}
}
public void closeDB(){
//verbindung trennen
if (conn != null)
{
try
{
conn.close();
//System.out.println("Connection closed.");
}
catch(SQLException sqle)
{
//System.out.print(sqle.getMessage());
}
}
}
public void datenAuslagern(){
try{
mysqlStatement = ("INSERT INTO `4cast_data` ( `ID` , `date` , `direct` , `temp` , `wind` , `air` , `light` , `pre` ) VALUES ('', '" + dateVar + "', '" + directVar + "', '" + tempVar + "', '" + windVar + "', '" + airVar + "', '" + lightVar + "', '" + preVar + "')");
statement = conn.createStatement();
ResultSet rs = statement.executeQuery(mysqlStatement);
}
catch(Exception add){
System.out.println("Fehlermeldung:" + add.getMessage());
}
}
public void setDate(String dateTemp){
dateVar = dateTemp;
}
public void setTemp(double tempTemp){
tempVar = tempTemp;
}
public void setAir(double airTemp){
airVar = airTemp;
}
public void setPre(double preTemp){
preVar = preTemp;
}
public void setWind(double windTemp){
windVar = windTemp;
}
public void setLight(double lightTemp){
lightVar = lightTemp;
}
public void setDirect(int directTemp){
directVar = directTemp;
}
}
vielen dank im voraus für die hilfe!