Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql query

Status
Not open for further replies.

gargon1

IS-IT--Management
Jan 24, 2003
15
0
0
VI
Please help,
Am trying to use the query below to return data from a mysql database but when I try compiling am receiving the following errors:

com\time\timeclock.java:84: unclosed string literal
("SELECT clocknum,date0,time0,fname,lname,dept,status FROM time_
sheet WHERE dept = ? AND
^
com\time\timeclock.java:85: unclosed string literal
date0 >= ? and date0 <= ? ORDER BY fname&quot;, ResultSet.TYPE_SCROLL_SENSITIVE, Resu
ltSet.CONCUR_READ_ONLY);

########## Method with SQL Query ######################
public ResultSet getUsers(String mydept, String sdate, String edate) throws SQLException, Exception {
ResultSet rst= null;
try {
PreparedStatement queryTimesheet = con.prepareStatement
(&quot;SELECT clocknum,date0,time0,fname,lname,dept,status FROM time_sheet WHERE dept = ? AND
date0 >= ? and date0 <= ? ORDER BY fname&quot;, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);

queryTimesheet.setString(1, mydept);
queryTimesheet.setString(2, sdate);
queryTimesheet.setString(3, edate);

rst = queryTimesheet.executeQuery();

} catch (SQLException sqle) {
error = &quot;SQLException: Could not execute query.&quot;;
throw new SQLException(error);
} catch (Exception e) {
error = &quot;An exception has occured while retrieving data,&quot;;
throw new Exception(error);
}
return rst;
}
 
the problem is in the following lines of code
Code:
 PreparedStatement queryTimesheet = con.prepareStatement
        (&quot;SELECT clocknum,date0,time0,fname,lname,dept,status FROM time_sheet WHERE dept = ? AND 
date0 >= ? and date0 <= ? ORDER BY fname&quot;, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);

Change/correct your code to look like:

Code:
PreparedStatement queryTimesheet = con.prepareStatement(&quot;SELECT clocknum,date0,time0,fname,lname,dept,status FROM time_sheet WHERE dept = ? AND &quot; +
&quot;date0 >= ? and date0 <= ? ORDER BY fname&quot;, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY
 
That did it. Thanks Dude!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top