public static void Rule1()
{
Connection con = null;
Statement st = null;
ResultSet rs = null;
int updateQuery=0;
String url = "jdbc:mysql://localhost:3306/test";
String user = "root";
String password = "aiman";
/***************/
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance(); // Load JBBC driver "com.mysql.jdbc.Driver".
con = DriverManager.getConnection(url, "root", "aiman");/*Create a connection*/
st = con.createStatement();
/***count rows**/
int count=0;
ResultSet res = st.executeQuery("SELECT COUNT(*) FROM feature");
while (res.next())
{
count = res.getInt(1);
}
System.out.println("Number of rows:"+count);
/*****************************Inserting Values**************************/
String w1,w2;
String nsubj="nsubj";
String query[] ={"SELECT * FROM Dependency WHERE header like 'nsubj'"};
System.out.println("before printing");
for(String q : query)
{
res = st.executeQuery(q);
//System.out.println("Names for query "+ q +" are");
while (res.next())
{
String header = res.getString("header");
String wi = res.getString("wi");
String wj = res.getString("wj");
System.out.println(header+"|"+wi+"|"+wj);
ResultSet res1 = null;
Statement st1=null;
st1=con.createStatement();
String query1[] ={"SELECT * FROM tagtable WHERE word like 'wi' AND tag like '%NN%'"};
for(String q1 : query1)
{
res1 = st1.executeQuery(q1);
while (res1.next())
{
System.out.println("in the loop");
System.out.println("*******************");
String w = res1.getString("word");
String tag = res1.getString("tag");
System.out.println(w+"|"+tag);
}
}
res1.close();
}//end while
System.out.println("done");
}//end for
res.close();
st.close();
con.close();
/************************************************************************/
}//try ends
catch(Exception e)
{
System.out.println("Exception is = "+e);
}
}//rule 1 ends here
}//feature class ends
======================================================
the inner while loop which is :
while (res1.next())
{
System.out.println("in the loop");
System.out.println("*******************");
String w = res1.getString("word");
String tag = res1.getString("tag");
System.out.println(w+"|"+tag);
}
DOES NOT GET EXECUTED ! HELP !
help needed !inCitizen March 3, 2012 at 3:27 AM
public static void Rule1() { Connection con = null; Statement st = null; ResultSet rs = null; int updateQuery=0; String url = "jdbc:mysql://localhost:3306/test"; String user = "root"; String password = "aiman"; /***************/ try { Class.forName("com.mysql.jdbc.Driver").newInstance(); // Load JBBC driver "com.mysql.jdbc.Driver". con = DriverManager.getConnection(url, "root", "aiman");/*Create a connection*/ st = con.createStatement(); /***count rows**/ int count=0; ResultSet res = st.executeQuery("SELECT COUNT(*) FROM feature"); while (res.next()) { count = res.getInt(1); } System.out.println("Number of rows:"+count); /*****************************Inserting Values**************************/ String w1,w2; String nsubj="nsubj"; String query[] ={"SELECT * FROM Dependency WHERE header like 'nsubj'"}; System.out.println("before printing"); for(String q : query) { res = st.executeQuery(q); //System.out.println("Names for query "+ q +" are"); while (res.next()) { String header = res.getString("header"); String wi = res.getString("wi"); String wj = res.getString("wj"); System.out.println(header+"|"+wi+"|"+wj); ResultSet res1 = null; Statement st1=null; st1=con.createStatement(); String query1[] ={"SELECT * FROM tagtable WHERE word like 'wi' AND tag like '%NN%'"}; for(String q1 : query1) { res1 = st1.executeQuery(q1); while (res1.next()) { System.out.println("in the loop"); System.out.println("*******************"); String w = res1.getString("word"); String tag = res1.getString("tag"); System.out.println(w+"|"+tag); } } res1.close(); }//end while System.out.println("done"); }//end for res.close(); st.close(); con.close(); /************************************************************************/ }//try ends catch(Exception e) { System.out.println("Exception is = "+e); } }//rule 1 ends here }//feature class ends ====================================================== the inner while loop which is : while (res1.next()) { System.out.println("in the loop"); System.out.println("*******************"); String w = res1.getString("word"); String tag = res1.getString("tag"); System.out.println(w+"|"+tag); } DOES NOT GET EXECUTED ! HELP !
Post your Comment