/**
  * 
  * @throws Exception
  */
 public void testBug56122() throws Exception {
     for (final Connection testConn : new Connection[] { this.conn, getFailoverConnection(), getLoadBalancedConnection(),
             getMasterSlaveReplicationConnection() }) {
         testConn.createClob();
         testConn.createBlob();
         testConn.createNClob();
         testConn.createSQLXML();
         testConn.isValid(12345);
         testConn.setClientInfo(new Properties());
         testConn.setClientInfo("NAME", "VALUE");
         testConn.getClientInfo();
         testConn.getClientInfo("CLIENT");
         assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() {
             public Void call() throws Exception {
                 testConn.createArrayOf("A_TYPE", null);
                 return null;
             }
         });
         assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() {
             public Void call() throws Exception {
                 testConn.createStruct("A_TYPE", null);
                 return null;
             }
         });
     }
 }
 public Blob createBlob() throws SQLException {
   String methodCall = "createBlob()";
   try {
     return (Blob) reportReturn(methodCall, realConnection.createBlob());
   } catch (SQLException s) {
     reportException(methodCall, s);
     throw s;
   }
 }
 @Override
 public Blob createBlob() throws SQLException {
   return conn.createBlob();
 }
  @Override
  public Blob createBlob() throws SQLException {
    checkState();

    return conn.createBlob();
  }
  /**
   * This method is used for editing the details on songs
   *
   * @param s The song that is being changed, the details are changed on the command and updated
   *     here
   * @return An integer value indicating errors or success
   */
  @Override
  public int editDetails(Song s) {
    if (s != null) {
      Connection con = null;
      PreparedStatement ps = null;

      try {
        con = getConnection();
        Blob art = con.createBlob();
        art.setBytes(1, s.getArtwork());
        String query =
            "UPDATE "
                + TABLE_NAME
                + "SET "
                + FILENAME
                + " = ?,"
                + TITLE
                + " = ?,"
                + ARTIST
                + " = ?,"
                + ALBUM
                + " = ?,"
                + GENRE
                + " = ?,"
                + YEAR
                + " = ?,"
                + PRICE
                + " = ?,"
                + LICENSE
                + " = ?,"
                + ARTWORK
                + " = ?"
                + " WHERE "
                + SONGID
                + " = ?";
        ps = con.prepareStatement(query);
        ps.setString(1, s.getFilename());
        ps.setString(2, s.getTitle());
        ps.setString(3, s.getArtist());
        ps.setString(4, s.getAlbum());
        ps.setString(5, s.getGenre());
        ps.setInt(6, s.getYear());
        ps.setDouble(7, s.getPrice());
        ps.setString(8, s.getLicense());
        ps.setBlob(9, art);
        ps.setInt(10, s.getSongId());
        int result = ps.executeUpdate();

        if (result > 0) return SUCCESS;
      } catch (SQLException ex2) {
        if (DEBUG) ex2.printStackTrace();
      } finally {
        try {
          if (ps != null) ps.close();
          if (con != null) freeConnection(con);
        } catch (SQLException e) {
          if (DEBUG) e.printStackTrace();
        }
      }
    }
    return OTHER;
  }
  /**
   * This method is used for adding a new song to the database
   *
   * @param s The song you wish to add to the database
   * @return SUCCESS if it successfully inserted, otherwise OTHER
   */
  @Override
  public int addNewSong(Song s) {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      con = getConnection();
      Blob data = con.createBlob();
      Blob art = con.createBlob();
      try {
        if (s.getSongdata() != null) data.setBytes(1, s.getSongdata());
        if (s.getArtwork() != null) art.setBytes(1, s.getArtwork());
      } catch (Exception e) {
        if (DEBUG) e.printStackTrace();
      }
      String query =
          "INSERT INTO "
              + TABLE_NAME
              + " ("
              + FILENAME
              + ", "
              + TITLE
              + ", "
              + ARTIST
              + ", "
              + ALBUM
              + ", "
              + GENRE
              + ", "
              + YEAR
              + ", "
              + DURATION
              + ", "
              + PRICE
              + ", "
              + LICENSE
              + ", "
              + PLAYCOUNT
              + ", "
              + UPLOADDATE
              + ", "
              + ARTWORK
              + ", "
              + SONGDATA
              + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
      ps = con.prepareStatement(query);
      ps.setString(1, s.getFilename());
      ps.setString(2, s.getTitle());
      ps.setString(3, s.getArtist());
      ps.setString(4, s.getAlbum());
      ps.setString(5, s.getGenre());
      ps.setInt(6, s.getYear());
      ps.setInt(7, s.getDuration());
      ps.setDouble(8, s.getPrice());
      ps.setString(9, s.getLicense());
      ps.setInt(10, s.getPlayCount());
      ps.setDate(11, s.getUploaded());
      ps.setBlob(12, art);
      ps.setBlob(13, data);
      if (ps.executeUpdate() > 0) return SUCCESS; // It successfully inserted into the database
    } catch (SQLException e) {
      if (DEBUG) e.printStackTrace();
    } finally {
      try {
        if (rs != null) rs.close();
        if (ps != null) ps.close();
        if (con != null) freeConnection(con);
      } catch (SQLException e) {
        if (DEBUG) e.printStackTrace();
        return SQLEX;
      }
    }
    return OTHER;
  }
 public Blob createBlob() throws SQLException {
   return connection.createBlob();
 }
  @Test
  public void testUnsupportedOperations() throws Exception {
    Connection conn = getConnection();

    try {
      conn.prepareCall(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.setReadOnly(false);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.setCatalog(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.getCatalog();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.prepareCall(null, 0, 0);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.setTypeMap(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.getTypeMap();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.setSavepoint();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.setSavepoint(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.rollback(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.releaseSavepoint(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.prepareCall(null, 0, 0, 0);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.createClob();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.createBlob();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.createNClob();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.createSQLXML();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.createArrayOf(null, (Object[]) null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.createStruct(null, (Object[]) null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.setSchema(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.getSchema();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.abort(null);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.setNetworkTimeout(null, 0);
      fail();
    } catch (UnsupportedOperationException ignore) {
    }

    try {
      conn.getNetworkTimeout();
      fail();
    } catch (UnsupportedOperationException ignore) {
    }
  }
  private void testUpdateDataType() throws Exception {
    Connection conn = getConnection();
    Statement stat = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    stat.execute(
        "CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255), "
            + "DEC DECIMAL(10,2), BOO BIT, BYE TINYINT, BIN BINARY(100), "
            + "D DATE, T TIME, TS TIMESTAMP, DB DOUBLE, R REAL, L BIGINT, "
            + "O_I INT, SH SMALLINT, CL CLOB, BL BLOB)");
    ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
    ResultSetMetaData meta = rs.getMetaData();
    assertEquals("java.lang.Integer", meta.getColumnClassName(1));
    assertEquals("java.lang.String", meta.getColumnClassName(2));
    assertEquals("java.math.BigDecimal", meta.getColumnClassName(3));
    assertEquals("java.lang.Boolean", meta.getColumnClassName(4));
    assertEquals("java.lang.Byte", meta.getColumnClassName(5));
    assertEquals("[B", meta.getColumnClassName(6));
    assertEquals("java.sql.Date", meta.getColumnClassName(7));
    assertEquals("java.sql.Time", meta.getColumnClassName(8));
    assertEquals("java.sql.Timestamp", meta.getColumnClassName(9));
    assertEquals("java.lang.Double", meta.getColumnClassName(10));
    assertEquals("java.lang.Float", meta.getColumnClassName(11));
    assertEquals("java.lang.Long", meta.getColumnClassName(12));
    assertEquals("java.lang.Integer", meta.getColumnClassName(13));
    assertEquals("java.lang.Short", meta.getColumnClassName(14));
    assertEquals("java.sql.Clob", meta.getColumnClassName(15));
    assertEquals("java.sql.Blob", meta.getColumnClassName(16));
    rs.moveToInsertRow();
    rs.updateInt(1, 0);
    rs.updateNull(2);
    rs.updateNull("DEC");
    // 'not set' values are set to null
    assertThrows(ErrorCode.NO_DATA_AVAILABLE, rs).cancelRowUpdates();
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt(1, 1);
    rs.updateString(2, null);
    rs.updateBigDecimal(3, null);
    rs.updateBoolean(4, false);
    rs.updateByte(5, (byte) 0);
    rs.updateBytes(6, null);
    rs.updateDate(7, null);
    rs.updateTime(8, null);
    rs.updateTimestamp(9, null);
    rs.updateDouble(10, 0.0);
    rs.updateFloat(11, (float) 0.0);
    rs.updateLong(12, 0L);
    rs.updateObject(13, null);
    rs.updateShort(14, (short) 0);
    rs.updateCharacterStream(15, new StringReader("test"), 0);
    rs.updateBinaryStream(16, new ByteArrayInputStream(new byte[] {(byte) 0xff, 0x00}), 0);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 2);
    rs.updateString("NAME", "+");
    rs.updateBigDecimal("DEC", new BigDecimal("1.2"));
    rs.updateBoolean("BOO", true);
    rs.updateByte("BYE", (byte) 0xff);
    rs.updateBytes("BIN", new byte[] {0x00, (byte) 0xff});
    rs.updateDate("D", Date.valueOf("2005-09-21"));
    rs.updateTime("T", Time.valueOf("21:46:28"));
    rs.updateTimestamp("TS", Timestamp.valueOf("2005-09-21 21:47:09.567890123"));
    rs.updateDouble("DB", 1.725);
    rs.updateFloat("R", (float) 2.5);
    rs.updateLong("L", Long.MAX_VALUE);
    rs.updateObject("O_I", 10);
    rs.updateShort("SH", Short.MIN_VALUE);
    // auml, ouml, uuml
    rs.updateCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"), 0);
    rs.updateBinaryStream("BL", new ByteArrayInputStream(new byte[] {(byte) 0xab, 0x12}), 0);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 3);
    rs.updateCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"));
    rs.updateBinaryStream("BL", new ByteArrayInputStream(new byte[] {(byte) 0xab, 0x12}));
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 4);
    rs.updateCharacterStream(15, new StringReader("\u00ef\u00f6\u00fc"));
    rs.updateBinaryStream(16, new ByteArrayInputStream(new byte[] {(byte) 0xab, 0x12}));
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 5);
    rs.updateClob("CL", new StringReader("\u00ef\u00f6\u00fc"));
    rs.updateBlob("BL", new ByteArrayInputStream(new byte[] {(byte) 0xab, 0x12}));
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 6);
    rs.updateClob(15, new StringReader("\u00ef\u00f6\u00fc"));
    rs.updateBlob(16, new ByteArrayInputStream(new byte[] {(byte) 0xab, 0x12}));
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 7);
    rs.updateNClob("CL", new StringReader("\u00ef\u00f6\u00fc"));
    Blob b = conn.createBlob();
    OutputStream out = b.setBinaryStream(1);
    out.write(new byte[] {(byte) 0xab, 0x12});
    out.close();
    rs.updateBlob("BL", b);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 8);
    rs.updateNClob(15, new StringReader("\u00ef\u00f6\u00fc"));
    rs.updateBlob(16, b);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 9);
    rs.updateNClob("CL", new StringReader("\u00ef\u00f6\u00fc"), -1);
    rs.updateBlob("BL", b);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 10);
    rs.updateNClob(15, new StringReader("\u00ef\u00f6\u00fc"), -1);
    rs.updateBlob(16, b);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 11);
    rs.updateNCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"), -1);
    rs.updateBlob("BL", b);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 12);
    rs.updateNCharacterStream(15, new StringReader("\u00ef\u00f6\u00fc"), -1);
    rs.updateBlob(16, b);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 13);
    rs.updateNCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"));
    rs.updateBlob("BL", b);
    rs.insertRow();

    rs.moveToInsertRow();
    rs.updateInt("ID", 14);
    rs.updateNCharacterStream(15, new StringReader("\u00ef\u00f6\u00fc"));
    rs.updateBlob(16, b);
    rs.insertRow();

    rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID NULLS FIRST");
    rs.next();
    assertTrue(rs.getInt(1) == 0);
    assertTrue(rs.getString(2) == null && rs.wasNull());
    assertTrue(rs.getBigDecimal(3) == null && rs.wasNull());
    assertTrue(!rs.getBoolean(4) && rs.wasNull());
    assertTrue(rs.getByte(5) == 0 && rs.wasNull());
    assertTrue(rs.getBytes(6) == null && rs.wasNull());
    assertTrue(rs.getDate(7) == null && rs.wasNull());
    assertTrue(rs.getTime(8) == null && rs.wasNull());
    assertTrue(rs.getTimestamp(9) == null && rs.wasNull());
    assertTrue(rs.getDouble(10) == 0.0 && rs.wasNull());
    assertTrue(rs.getFloat(11) == 0.0 && rs.wasNull());
    assertTrue(rs.getLong(12) == 0 && rs.wasNull());
    assertTrue(rs.getObject(13) == null && rs.wasNull());
    assertTrue(rs.getShort(14) == 0 && rs.wasNull());
    assertTrue(rs.getCharacterStream(15) == null && rs.wasNull());
    assertTrue(rs.getBinaryStream(16) == null && rs.wasNull());

    rs.next();
    assertTrue(rs.getInt(1) == 1);
    assertTrue(rs.getString(2) == null && rs.wasNull());
    assertTrue(rs.getBigDecimal(3) == null && rs.wasNull());
    assertTrue(!rs.getBoolean(4) && !rs.wasNull());
    assertTrue(rs.getByte(5) == 0 && !rs.wasNull());
    assertTrue(rs.getBytes(6) == null && rs.wasNull());
    assertTrue(rs.getDate(7) == null && rs.wasNull());
    assertTrue(rs.getTime(8) == null && rs.wasNull());
    assertTrue(rs.getTimestamp(9) == null && rs.wasNull());
    assertTrue(rs.getDouble(10) == 0.0 && !rs.wasNull());
    assertTrue(rs.getFloat(11) == 0.0 && !rs.wasNull());
    assertTrue(rs.getLong(12) == 0 && !rs.wasNull());
    assertTrue(rs.getObject(13) == null && rs.wasNull());
    assertTrue(rs.getShort(14) == 0 && !rs.wasNull());
    assertEquals("test", rs.getString(15));
    assertEquals(new byte[] {(byte) 0xff, 0x00}, rs.getBytes(16));

    rs.next();
    assertTrue(rs.getInt(1) == 2);
    assertEquals("+", rs.getString(2));
    assertEquals("1.20", rs.getBigDecimal(3).toString());
    assertTrue(rs.getBoolean(4));
    assertTrue((rs.getByte(5) & 0xff) == 0xff);
    assertEquals(new byte[] {0x00, (byte) 0xff}, rs.getBytes(6));
    assertEquals("2005-09-21", rs.getDate(7).toString());
    assertEquals("21:46:28", rs.getTime(8).toString());
    assertEquals("2005-09-21 21:47:09.567890123", rs.getTimestamp(9).toString());
    assertTrue(rs.getDouble(10) == 1.725);
    assertTrue(rs.getFloat(11) == (float) 2.5);
    assertTrue(rs.getLong(12) == Long.MAX_VALUE);
    assertEquals(10, ((Integer) rs.getObject(13)).intValue());
    assertTrue(rs.getShort(14) == Short.MIN_VALUE);
    // auml ouml uuml
    assertEquals("\u00ef\u00f6\u00fc", rs.getString(15));
    assertEquals(new byte[] {(byte) 0xab, 0x12}, rs.getBytes(16));

    for (int i = 3; i <= 14; i++) {
      rs.next();
      assertEquals(i, rs.getInt(1));
      assertEquals("\u00ef\u00f6\u00fc", rs.getString(15));
      assertEquals(new byte[] {(byte) 0xab, 0x12}, rs.getBytes(16));
    }
    assertFalse(rs.next());

    stat.execute("DROP TABLE TEST");
    conn.close();
  }
 @Override
 public Blob createBlob() throws SQLException {
   return _wrapped.createBlob();
 }