I know a lot has changed in JBossCX since 3.0, but I don't have a CHANGELOG
yet. I looked at the source, but my code below is now throwing null pointer
exceptions...

Any ideas?

Hunter

    private int getNextVal(String seqName) throws SQLException {
        int nextVal = -1;
        Connection myConnection = null;
        DataSource datasource = null;
        
        try {
            InitialContext jndiContext = new InitialContext();
            
            datasource = (DataSource)jndiContext.lookup("java:/RateVegas");
            
            myConnection = datasource.getConnection("postgres","whatever");

            ResultSet rs;
            PreparedStatement pstmt;
            String query = "";

            query = "SELECT NEXTVAL(?)";

            pstmt = myConnection.prepareStatement(query);
            pstmt.setString(1,seqName);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                nextVal = rs.getInt(1);
            }
            rs.close();
        }
        catch (SQLException ex) {
            throw ex;
        }
        catch (Exception e) {
            System.out.println(e.toString());
        }
        finally {
            myConnection.close();
        }
        return nextVal;
    }



-------------------------------------------------------
This SF.NET email is sponsored by: AMD - Your access to the experts
on Hammer Technology! Open Source & Linux Developers, register now
for the AMD Developer Symposium. Code: EX8664
http://www.developwithamd.com/developerlab
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to