Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes rst.updateString(..) not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "rst.updateString(..) not working" Watch "rst.updateString(..) not working" New topic
Author

rst.updateString(..) not working

vikhyath reddy
Greenhorn

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 :


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

con=DriverManager.getConnection(url);
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(rst.next()){i++;} // check no. of records
m=i;i=0;
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;");
while(rst.next())
{

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

rst.updateString(1,g1);
rst.updateString(2,g2);
rst.updateString(3,g3);

out.println(g1+" "+g2+" "+g3); // *********** NOT GETTING THE output
rst.updateRow();
c=1;r=r+10;
} // 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: http://faq.javaranch.com/java/TellTheDetails
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
vikhyath reddy
Greenhorn

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: rst.updateString(..) not working
 
Similar Threads
jdbc resultset to xml
problem with ResultSet
How do I put a ResultSet into an Array?
JSP with Jdbc
Famous "Object expected"error,Wishing Browser Independent