If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Java function exception

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-01-06, 10:58
Syncho Syncho is offline
Registered User
 
Join Date: May 2006
Posts: 5
Java function exception

Hello,

I call a java function from a stored procedure, but an error for an exception is generated. Below are the code and error log, it seems I am not allowed to call first() on result set. What's wrong with this?

Log message :
java.sql.SQLException: [IBM][JDBC .......] CLI0627E ............ ..... .. . ...........
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throwNo tScrollable(SQLExceptionGenerator.java:763)
at COM.ibm.db2.jdbc.app.DB2ResultSet.first(DB2ResultS et.java:3207)
at F_SYS.f_sys_langid(f_sys_langid.java:17)

Code:
import java.sql.*;

class F_SYS
{
public static int f_sys_langid()
throws SQLException
{
int outparm;
Connection con = DriverManager.getConnection( "jdbc:default:connection" );
PreparedStatement stmt = null;
String sql = "select Lang_ID from SESSION.glb_sysinfo fetch first ROW ONLY";

stmt = con.prepareStatement( sql );

ResultSet rs = stmt.executeQuery();
rs.first();
outparm = rs.getInt(1);
if (rs != null) rs.close();

if (stmt != null) stmt.close();
if (con != null) con.close();

return outparm;
}
}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On