hi and good day to all,
i have a problem with my data from the mysql. i have string data from the db and want to process in program(java app),but no out appeared.i suspect something is wrong with the input because, there is no problem if i run with direct input.
this is code to query data from mysql.Example input: 2,2,2,2 is in string
public static void main (String[] args)
{
Connection conn = null;
String input = new String();
int t=0;
int id =0;
try
{
//register jdbc driver for mysql
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
//define url of db on localhost
String url = "jdbc:mysql://localhost/t-way";
//get connection to d db for s username n password
String userName = "root";
String password = "anything";
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("URL "+url);
Statement s = conn.createStatement();
//execute sql statement
ResultSet rs = s.executeQuery("SELECT * FROM input WHERE 'check'=0");
int count=0;
while (rs.next())
{
id= rs.getInt("id");
input= rs.getString("in");
t = rs.getInt("number");
++count;
}
rs.close();
s.close();
Process go = new Process(input , t);
go.release();
}
i can get data from this code and can pass it to Process class
this is code to give direct input to Process class
public class Try
{
public static void main(String[] args)
{
Process go = new Process("2,2,2,2" , 2);
go.release();
}
}
the Process goes well and i got the output. i have no idea whats the problem but i suspect the content of the string is different between direct input n db