Home Discussion Discuss: JDBC Nested Resultset

  • 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



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
JDBC

JDBC Nested Resultset
JDBC Nested Resultset       The JDBC Nested Result Set  is the simplest join... you a code that helps in understanding JDBC Nested Result Set. The code include 

JDBC Questions

ResultSet
ResultSet   What is a ResultSet 

Java Interview Questions

ResultSet
ResultSet  What is a ResultSet 

HTML Questions

nested select tag
nested select tag  My requirement is as follows suppose combobox...(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); Statement stmt = con.createStatement(); ResultSet rs 

JDBC Questions

ResultSet
ResultSet  I want to retrieve data of unknown datatype from database.how to do it using resultset or Resultsetmetadata.Can you please tell me what... = con.createStatement(); ResultSet rs = st.executeQuery 

JDBC Questions

multiple resultset in one resultset
multiple resultset in one resultset  how to retrive multiple resultsets in one resultset in java.? plz help 

Java Interview Questions

Nested class
Nested class  What is nested class?  when a class is defined within another class then such a class is called a nested class. Nested... nested classes are: It is a way of logically grouping classes that are only used 

Java Beginners

nested loops
nested loops  please tell input to get the output: 12345 23456 34567 45678 

Java Beginners

Nested try
Nested try  Hi, In eclipse without providing input i am getting different outputs ie my exception gets executed first then finally block and vice versa.pl explain me class Demo { static void nestedTry(String args[]) { try 

Java Beginners

nested for-loop
nested for-loop  hi.write a program that will prompt the user for a positive integer(num) and then display two triangles with num number of lines to represent the following patterns of asterisks. the input num must be validated 

IDE Questions

Nested try
Nested try  Each time when i execute this code in eclipse i get different answers pl help me with this code class Demo { static void nestedTry..., visit the following link: Nested Try Example 

WebSevices Questions

resultset metadta
resultset metadta  import java.sql.Connection; import... Employee Details Using resultset metadata: "); Connection con = null; String url = "jdbc:oracle:thin:@172.24.137.30:1521:ORA10G 

Java Beginners

nested for loops
nested for loops  Hello all, I have created a program(gui) that allows a user to input time and minutes in textfields and then calculates... that the problem lies with my nested for loop which calculates all information 

HTML Questions

program to create nested tables
program to create nested tables  program to create nested tables 

Java Technology Tutorials

Nested classes: Examples and tutorials
Nested classes: Examples and tutorials       Nested classes Here is another advantage of the Java... within another class, such class is called a nested class. Inner classes can 

Java Beginners

The nested class - Java Beginners
The nested class  Hi, What is nested class in Java? What is the benefits of nested class? Write examples of nested class. Thanks   .../java/n/java-nested-class.shtml Thanks 

JDBC Questions

GROUP BY IN NESTED QUERY
GROUP BY IN NESTED QUERY  Hello Every One, Query to use GROUP BY CLAUSE IN NESTED QUERY SELECT STATEMENT in mysql database.If u know please help me.thanks 

JDBC Questions

The cursor in scrollable resultset
The cursor in scrollable resultset   How to move the cursor in scrollable resultset 

JDBC Questions

Update a resultset programmatically
Update a resultset programmatically  How to update a resultset programmatically 

Java Beginners

Java nested class example
Java nested class example  Give me any example of Nested Class.   Nested Class: Class defined within another class is called nested class. Nested class is divided into two parts- 1.Static 2.Non-static Static 

JDBC Questions

Need help with nested queries
Need help with nested queries  Hello, Table1 has "id", "votes" columns. Table2 has "id", "Name" column. I need to retrieve Name and its corresponging Votes. I tried with nested queries but its confusing. Can anyone please help 

JSP Tutorials

Nested If Statement
Nested If Statement       In this section you will study about the Nested-if Statement in jsp. Nested If statement means to use the if statement inside the other if statement 

Java Beginners

Nested and Inner classes
Nested and Inner classes  What is the significance of Inner Classes and Static Inner Classes? or Why are nested classes used?   Hi Friend... a nested class. Inner class is a non static class declared inside another class.Non 

Java Beginners

Using Nested loops
Using Nested loops  How to use nested loops in java when I want to print the 10 multiples of numbers 2 to 15(in multiplication table)   public class MultiplicationTable{ public static void main(String[] args) { int 

JSP Servlet Questions

Resultset - JSP-Servlet
Resultset  I am writing while(rs.next){} but if resultset is null then it cannot enter in while block. I want,if resultset is null then it will enter into the while block.  Hi friend, A ResultSet object 

JDBC Questions

SQL exception, Exhausted ResultSet
SQL exception, Exhausted ResultSet  javax.servlet.ServletException: java.sql.SQLException: Exhausted Resultset iam getting this error messege whenever i run my code. what would be the possible reasons 

Java Beginners

Nested Loop - Java Beginners
Nested Loop  Hi, Can anyone tell me example of Nested loop in Java? Thanks   Hi friend,public class NestedExample{ public static void main(String[] args){ /** Print Pattern I */ System.out.println(" 

JSP Servlet Questions

resultset problem - JSP-Servlet
resultset problem  hi I have one problem with resultset? ResultSet rs=st.execute("select subjname,staffname from staffdetails"); while... is java.sql.SQLException: Operation not allowed after ResultSet closed how 

Ajax Questions

Nested Ajax--not getting output
Nested Ajax--not getting output  Hi everyone... I have two.jsp page from that , with the help of ajax i have called three.jsp. So, i have used DIV in my jsp pages . on button click,It gives me my desired answer. Same,in next 

General

Static Nested Classes
Static Nested Classes       A nested class that is declared static is called a static nested class. Memory to the objects of  any static nested classes are allocated 

DMCA.com