src/share/classes/com/sun/rowset/JdbcRowSetImpl.java

Print this page




 651                 }
 652             }
 653             catch (javax.naming.NamingException ex) {
 654                 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.connect").toString());
 655             }
 656 
 657         } else if (getUrl() != null) {
 658             // Check only for getUrl() != null because
 659             // user, passwd can be null
 660             // Connect using the driver manager.
 661 
 662             return DriverManager.getConnection
 663                     (getUrl(), getUsername(), getPassword());
 664         }
 665         else {
 666             return null;
 667         }
 668 
 669     }
 670 
 671 
 672     protected PreparedStatement prepare() throws SQLException {
 673         // get a connection
 674         conn = connect();
 675 
 676         try {
 677 
 678             Map<String, Class<?>> aMap = getTypeMap();
 679             if( aMap != null) {
 680                 conn.setTypeMap(aMap);
 681             }
 682             ps = conn.prepareStatement(getCommand(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
 683         } catch (SQLException ex) {
 684             System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.prepare").toString() +
 685                                 ex.getLocalizedMessage());
 686 
 687             if (ps != null)
 688                 ps.close();
 689             if (conn != null)
 690                 conn.close();
 691 
 692             throw new SQLException(ex.getMessage());
 693         }
 694 
 695         return ps;
 696     }
 697 

 698     private void decodeParams(Object[] params, PreparedStatement ps)
 699     throws SQLException {
 700 
 701     // There is a corresponding decodeParams in JdbcRowSetImpl
 702     // which does the same as this method. This is a design flaw.
 703     // Update the CachedRowsetReader.decodeParams when you update
 704     // this method.
 705 
 706     // Adding the same comments to CachedRowsetReader.decodeParams.
 707 
 708         int arraySize;
 709         Object[] param = null;
 710 
 711         for (int i=0; i < params.length; i++) {
 712             if (params[i] instanceof Object[]) {
 713                 param = (Object[])params[i];
 714 
 715                 if (param.length == 2) {
 716                     if (param[0] == null) {
 717                         ps.setNull(i + 1, ((Integer)param[1]).intValue());




 651                 }
 652             }
 653             catch (javax.naming.NamingException ex) {
 654                 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.connect").toString());
 655             }
 656 
 657         } else if (getUrl() != null) {
 658             // Check only for getUrl() != null because
 659             // user, passwd can be null
 660             // Connect using the driver manager.
 661 
 662             return DriverManager.getConnection
 663                     (getUrl(), getUsername(), getPassword());
 664         }
 665         else {
 666             return null;
 667         }
 668 
 669     }
 670 

 671     protected PreparedStatement prepare() throws SQLException {
 672         // get a connection
 673         conn = connect();
 674 
 675         try {
 676 
 677             Map<String, Class<?>> aMap = getTypeMap();
 678             if( aMap != null) {
 679                 conn.setTypeMap(aMap);
 680             }
 681             ps = conn.prepareStatement(getCommand(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
 682         } catch (SQLException ex) {
 683             System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.prepare").toString() +
 684                                 ex.getLocalizedMessage());
 685 
 686             if (ps != null)
 687                 ps.close();
 688             if (conn != null)
 689                 conn.close();
 690 
 691             throw new SQLException(ex.getMessage());
 692         }
 693 
 694         return ps;
 695     }
 696 
 697     @SuppressWarnings("deprecation")
 698     private void decodeParams(Object[] params, PreparedStatement ps)
 699     throws SQLException {
 700 
 701     // There is a corresponding decodeParams in JdbcRowSetImpl
 702     // which does the same as this method. This is a design flaw.
 703     // Update the CachedRowsetReader.decodeParams when you update
 704     // this method.
 705 
 706     // Adding the same comments to CachedRowsetReader.decodeParams.
 707 
 708         int arraySize;
 709         Object[] param = null;
 710 
 711         for (int i=0; i < params.length; i++) {
 712             if (params[i] instanceof Object[]) {
 713                 param = (Object[])params[i];
 714 
 715                 if (param.length == 2) {
 716                     if (param[0] == null) {
 717                         ps.setNull(i + 1, ((Integer)param[1]).intValue());