I want to shift the value in columns after comparision. I am having problem with the getString command. It results in an error ….my code is like this

for(p=1;p<20;p++)
                                        {
                                           Class.forName("com.mysql.jdbc.Driver");
                                            Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/srch","root","");
                                            Statement stmt2=con.createStatement();

                                            ResultSet rs2=stmt2.executeQuery("select * from "+tbl+"c"+startc+" where keyword='"+sk[i]+"'");

                                            cnt=0;
                                            if(rs1.findColumn("count"+p) > 0)

                                            {

                                            
                                            System.out.println("count"+p);
                                            cnt=rs2.getInt("count"+p);
                                            if(cnt > (occ+1))
                                            {

                                            }
                                            else if(cnt < (occ+1))
                                            {
                                                q=p;
                                                break;
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                            
                                            con.close();
                                        }

Edited 6 Years Ago by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

It results in an error ….

could you be just a tad more specific about this part?
what error is thrown, what error message do you get, where is it thrown, ...

could you be just a tad more specific about this part?
what error is thrown, what error message do you get, where is it thrown, ...

I am getting "java.sql.SQLEXCEPTION" at cnt=rs2.getInt("count"+p); line no. 16.... See the problem is it is able to find column ("count"+p) but it is unable to get its value...how can it be posssible?

Uhm, because a column ("count" + p) doesn't exist, in that ResultSet?

The rest of that exception would be helpful though.

hey it exists otherwise how it can satisfy the if condition.......
and the stacktrace :
java.sql.SQLException
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:815)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2593)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2734)
at crawler.Count.count(Count.java:177)
at crawler.Crawl.main(Crawl.java:49)

hey it exists otherwise how it can satisfy the if condition.......

Because the if uses rs1 and the get uses rs2.

Edited 6 Years Ago by masijade: n/a

This article has been dead for over six months. Start a new discussion instead.