Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rst.updateString(..) not working

 
vikhyath reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vikhyath,
Can you post the exception that is getting thrown by the code?
 
vikhyath reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic