/** * * @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 Clob createClob() throws SQLException { String methodCall = "createClob()"; try { return (Clob) reportReturn(methodCall, realConnection.createClob()); } catch (SQLException s) { reportException(methodCall, s); throw s; } }
@Override public Clob createClob() throws SQLException { checkState(); try { return conn.createClob(); } catch (SQLException ex) { handleException(ex); return null; // never arrive } }
/** * Creates an item object from String parameters. * * @param conn connection to database * @param param map of parameters to set * @return an item object */ public static Item createItem(Connection conn, Map<String, String[]> param) throws SQLException { Item item = new Item(); item.setName(param.get("name")[0]); item.setPrice(Integer.parseInt(param.get("price")[0])); item.setQuantity(Integer.parseInt(param.get("quantity")[0])); Clob cl = conn.createClob(); cl.setString(1, param.get("description")[0]); item.setDescription(cl); item.setStringDescr(cl); return item; }
public static void saveKit(final Player p) { if (kit.get(p) != null) { ItemStack five = kit.get(p).getItem(5); ItemStack six = kit.get(p).getItem(6); kit.get(p).setItem(5, null); kit.get(p).setItem(6, null); if (!(MySQL.mySQLenabled())) { KitFile.getData().set("Kit." + p.getUniqueId(), SaveAndLoad.toString(kit.get(p))); KitFile.saveData(); KitFile.reloadData(); } else { String INSERT = "INSERT INTO CODKits VALUES(?, ?) ON DUPLICATE KEY UPDATE list=?"; try { Connection conn = MySQL.getConnection(); PreparedStatement ps = conn.prepareStatement(INSERT); ps.setString(1, p.getUniqueId().toString()); Clob clob = conn.createClob(); ArrayList<String> list = SaveAndLoad.toString(kit.get(p)); clob.setString(1, MySQL.listToString(list)); ps.setClob(2, clob); ps.setClob(3, clob); ps.executeUpdate(); ps.close(); conn.close(); } catch (Exception e) { e.printStackTrace(); } } kit.get(p).setItem(5, five); kit.get(p).setItem(6, six); } else { return; } }
private void testInsertRowWithUpdatableResultSetDefault() throws Exception { stat.execute("create table test(id int primary key, " + "data varchar(255) default 'Hello')"); PreparedStatement prep = conn.prepareStatement( "select * from test", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = prep.executeQuery(); rs.moveToInsertRow(); rs.updateInt(1, 1); rs.insertRow(); rs.close(); rs = stat.executeQuery("select * from test"); assertTrue(rs.next()); assertEquals("Hello", rs.getString(2)); assertEquals("Hello", rs.getString("data")); assertEquals("Hello", rs.getNString(2)); assertEquals("Hello", rs.getNString("data")); assertEquals("Hello", IOUtils.readStringAndClose(rs.getNCharacterStream(2), -1)); assertEquals("Hello", IOUtils.readStringAndClose(rs.getNCharacterStream("data"), -1)); assertEquals("Hello", IOUtils.readStringAndClose(rs.getNClob(2).getCharacterStream(), -1)); assertEquals("Hello", IOUtils.readStringAndClose(rs.getNClob("data").getCharacterStream(), -1)); rs = prep.executeQuery(); rs.moveToInsertRow(); rs.updateInt(1, 2); rs.updateNString(2, "Hello"); rs.insertRow(); rs.moveToInsertRow(); rs.updateInt(1, 3); rs.updateNString("data", "Hello"); rs.insertRow(); Clob c; Writer w; rs.moveToInsertRow(); rs.updateInt(1, 4); c = conn.createClob(); w = c.setCharacterStream(1); w.write("Hello"); w.close(); rs.updateClob(2, c); rs.insertRow(); rs.moveToInsertRow(); rs.updateInt(1, 5); c = conn.createClob(); w = c.setCharacterStream(1); w.write("Hello"); w.close(); rs.updateClob("data", c); rs.insertRow(); InputStream in; rs.moveToInsertRow(); rs.updateInt(1, 6); in = new ByteArrayInputStream("Hello".getBytes("UTF-8")); rs.updateAsciiStream(2, in); rs.insertRow(); rs.moveToInsertRow(); rs.updateInt(1, 7); in = new ByteArrayInputStream("Hello".getBytes("UTF-8")); rs.updateAsciiStream("data", in); rs.insertRow(); rs.moveToInsertRow(); rs.updateInt(1, 8); in = new ByteArrayInputStream("Hello-".getBytes("UTF-8")); rs.updateAsciiStream(2, in, 5); rs.insertRow(); rs.moveToInsertRow(); rs.updateInt(1, 9); in = new ByteArrayInputStream("Hello-".getBytes("UTF-8")); rs.updateAsciiStream("data", in, 5); rs.insertRow(); rs.moveToInsertRow(); rs.updateInt(1, 10); in = new ByteArrayInputStream("Hello-".getBytes("UTF-8")); rs.updateAsciiStream(2, in, 5L); rs.insertRow(); rs.moveToInsertRow(); rs.updateInt(1, 11); in = new ByteArrayInputStream("Hello-".getBytes("UTF-8")); rs.updateAsciiStream("data", in, 5L); rs.insertRow(); rs = stat.executeQuery("select * from test"); while (rs.next()) { assertEquals("Hello", rs.getString(2)); } stat.execute("drop table test"); }
@Override public Clob createClob() throws SQLException { return conn.createClob(); }
public Clob createClob() throws SQLException { return connection.createClob(); }
@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) { } }
@Override public Clob createClob() throws SQLException { checkState(); return conn.createClob(); }
@Override public Clob createClob() throws SQLException { return _wrapped.createClob(); }