The moose likes JDBC and Relational Databases and the fly likes rst.updateString(..) not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "rst.updateString(..) not working" Watch "rst.updateString(..) not working" New topic

rst.updateString(..) not working

vikhyath reddy

Joined: Dec 07, 2008
Posts: 20
hello everybody , nice to be back .. i started having some problems with rst.updateString(...) method.. here is my code :

String url="jdbc:mysql://localhost:3306/vikh?user=root&password=admin";

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); // **** guess there is a problem here
rst=stmt.executeQuery("select * from trial_auth1;");
ResultSetMetaData rsmd=rst.getMetaData();
int cnt=rsmd.getColumnCount();
while({i++;} // check no. of records
out.println("No. of rows : "+m+"
No. of colls : "+cnt);
int r=10;
int c=1;
rst=stmt.executeQuery("select * from trial_auth1 order by sid;");

String h1=Integer.toString(r+c);c++; // *** getting output here
String h2=Integer.toString(r+c);c++; // *** getting output here
String h3=Integer.toString(r+c); // *** getting output here

String g1=request.getParameter(h1);
String g2=request.getParameter(h2);
String g3=request.getParameter(h3);

out.println(g1+" "+g2+" "+g3); // *** getting output here


out.println(g1+" "+g2+" "+g3); // *********** NOT GETTING THE output
} // end of while

..... Thanks in advance

~ Happy coding ~
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Firstly, writing Java code in JSP files instead of in Java classes doesn't make it a JSP problem. You have a JDBC problem. There is a JDBC forum around. You should post future JDBC related problems over there. This thread will be moved by a moderator sooner or later, so you don't need to repost it again.

Regarding to your actual problem: well, I can't seem to understand the problem clearly. It's too general and vague. Only stating "I have problems" and posting a piece of unformatted code which no one is going to read isn't going to deliver good response here. Please read this how to explain your problem properly:
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [About Bear] [Books by Bear]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

Can you post the exception that is getting thrown by the code?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
vikhyath reddy

Joined: Dec 07, 2008
Posts: 20
what i want to ask is .. is there any relation between

Statement st=con.createStatement(* arguments *); and rs.updateString(int,"string") method ... like for rs.updateInt(int,int) i

had to create st as ---- st=con.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE); so what is

the appropriate syntax for updateString(int,"string"); when it comes to st .... thanks in advance !
vikhyath reddy

Joined: Dec 07, 2008
Posts: 20
this is the exception i am getting -----

com.mysql.jdbc.NotUpdatable: Result Set not updatable (referenced table has no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
I agree. Here's the link:
subject: rst.updateString(..) not working
jQuery in Action, 3rd edition