package bug;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class BugClass {
	
	Connection connection=null;
	String databaseURL="jdbc:mysql://192.168.1.2:3306/";
	String databaseName="ef";
	
	
	public BugClass() {
		super();
	}
	
	
	
	public void doTheBug(String usr, String pwd) throws Throwable{
		Class.forName("org.gjt.mm.mysql.Driver");
		this.connection=DriverManager.getConnection(this.databaseURL+this.databaseName,usr,pwd);
		Statement statement=this.connection.createStatement();
		statement.execute("insert into abrechnung (fk_Filiale, bezeichung) values (1,'€')");
		ResultSet resultSet=statement.executeQuery("select fk_Filiale, bezeichung from abrechnung where fk_Filiale=1");
		while(resultSet.next()) {
			System.err.println("FK Filiale: "+resultSet.getString(1)+" bezeichnung: "+resultSet.getString(2)+"\n");
		}
		/*
		 * OUTPUT START
		 * FK Filiale: 1 bezeichnung: ?
		 * OUTPUT END
		 * 
		 * the "?" is unexcpected 
		 */
	}
	
	
	public static void main(String[] args) {
		String usr=args[0];
		String pwd=args[1];
		BugClass bugClass=new BugClass();
		try {
			bugClass.doTheBug(usr,pwd);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}