This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL Exception!! 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 "SQL Exception!!" Watch "SQL Exception!!" New topic

SQL Exception!!

allen gu

Joined: Jan 13, 2003
Posts: 6
String sn=edit1.getText();
try {
Connection con=null;
ResultSet rs;
ResultSetMetaData md;
String url="jdbc dbc:test1";
Statement s=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql1="select Specialty from student where Sn='"+sn+"';" ;
rs=s.executeQuery(sql1);//sql1 is ok!
labeld.setText("Can not find!");
String specialty3=rs.getString("Specialty");
String sql2="select * from "+specialty3+" where Sn='"+sn+"';";
rs=s.executeQuery(sql2);// sql2 throw a sql Exception! "Illegal description index"
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 265
try this way
String sql2="select * from '"+specialty3+"' where Sn='"+sn+"';";
I agree. Here's the link:
subject: SQL Exception!!
Similar Threads
Not retrieving from the Java Bean
Error while inserting data into from a JSP Page
how to parse java.util.Date to ?
RMI Exception! Please give me a hand!