5268
5272
public int getBytesSize() throws SQLException {
5276
public java.sql.RowId getRowId(int columnIndex) throws SQLException {
5280
public java.sql.RowId getRowId(String columnLabel) throws SQLException {
5284
public void updateRowId(int columnIndex, java.sql.RowId x) throws SQLException {
5287
public void updateRowId(String columnLabel, java.sql.RowId x) throws SQLException {
5290
public int getHoldability() throws SQLException {
5294
public boolean isClosed() throws SQLException {
5298
public void updateNString(int columnIndex, String nString) throws SQLException {
5301
public void updateNString(String columnLabel, String nString) throws SQLException {
5304
public void updateNClob(int columnIndex, java.sql.NClob nClob) throws SQLException {
5307
public void updateNClob(String columnLabel, java.sql.NClob nClob) throws SQLException {
5310
public java.sql.NClob getNClob(int columnIndex) throws SQLException {
5314
public java.sql.NClob getNClob(String columnLabel) throws SQLException {
5318
public java.sql.SQLXML getSQLXML(int columnIndex) throws SQLException {
5322
public java.sql.SQLXML getSQLXML(String columnLabel) throws SQLException {
5326
public void updateSQLXML(int columnIndex, java.sql.SQLXML xmlObject) throws SQLException {
5329
public void updateSQLXML(String columnLabel, java.sql.SQLXML xmlObject) throws SQLException {
5332
public String getNString(int columnIndex) throws SQLException {
5336
public String getNString(String columnLabel) throws SQLException {
5340
public Reader getNCharacterStream(int columnIndex) throws SQLException {
5344
public Reader getNCharacterStream(String columnLabel) throws SQLException {
5348
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
5351
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
5354
public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
5357
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
5360
public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
5363
public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
5366
public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
5369
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
5372
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
5375
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
5378
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
5381
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
5384
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
5388
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
5391
public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
5394
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
5397
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
5400
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
5403
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
5406
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
5409
public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
5412
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
5415
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
5418
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
5421
public void updateClob(int columnIndex, Reader reader) throws SQLException {
5424
public void updateClob(String columnLabel, Reader reader) throws SQLException {
5427
public void updateNClob(int columnIndex, Reader reader) throws SQLException {
5430
public void updateNClob(String columnLabel, Reader reader) throws SQLException {
5433
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
5437
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
5441
public <T> T unwrap(Class<T> iface) throws SQLException {
5445
public boolean isWrapperFor(Class<?> iface) throws SQLException {
6760
public void testBug61501() throws Exception {
6761
createTable("testBug61501", "(id int)");
6762
stmt.executeUpdate("INSERT INTO testBug61501 VALUES (1)");
6763
String sql = "SELECT id FROM testBug61501 where id=1";
6764
pstmt = conn.prepareStatement(sql);
6765
pstmt.executeQuery();
6769
pstmt = conn.prepareStatement(sql);
6770
rs = pstmt.executeQuery();
6773
stmt.executeQuery(sql);
6776
pstmt = ((com.mysql.jdbc.Connection) conn).serverPrepareStatement(sql);
6781
sql = "INSERT INTO testBug61501 VALUES (2)";
6782
pstmt = conn.prepareStatement(sql);
6784
assertEquals(1, pstmt.getUpdateCount());
6788
pstmt = conn.prepareStatement(sql);
6789
assertEquals(1, pstmt.executeUpdate());
6792
assertEquals(1, stmt.executeUpdate(sql));
6795
assertEquals(1, stmt.getUpdateCount());
6797
pstmt = ((com.mysql.jdbc.Connection) conn).serverPrepareStatement(sql);
6799
assertEquals(1, pstmt.getUpdateCount());
6803
pstmt = ((com.mysql.jdbc.Connection) conn).serverPrepareStatement(sql);
6804
assertEquals(1, pstmt.executeUpdate());
6810
int[] counts = pstmt.executeBatch();
6812
for (int i = 0; i < counts.length; i++) {
6813
assertEquals(1, counts[i]);
6816
pstmt = conn.prepareStatement(sql);
6821
counts = pstmt.executeBatch();
6823
for (int i = 0; i < counts.length; i++) {
6824
assertEquals(1, counts[i]);
6832
counts = stmt.executeBatch();
6834
for (int i = 0; i < counts.length; i++) {
6835
assertEquals(1, counts[i]);
6841
public void testbug61866() throws Exception {
6843
createProcedure("WARN_PROCEDURE", "() BEGIN DECLARE l_done INT; SELECT 1 INTO l_done FROM DUAL WHERE 1=2; END");
6844
this.pstmt = this.conn.prepareCall("{CALL WARN_PROCEDURE()}");
6845
this.pstmt.execute();
6846
assertTrue("No warning when expected", this.pstmt.getWarnings().toString().contentEquals("java.sql.SQLWarning: No data - zero rows fetched, selected, or processed"));
6847
this.pstmt.clearWarnings();
6848
assertNull("Warning when not expected", this.pstmt.getWarnings());
6851
public void testbug12565726() throws Exception {
6852
// Not putting the space between VALUES() and ON DUPLICATE KEY UPDATE
6853
// causes C/J a) enter rewriting the query altrhough it has ON UPDATE
6854
// and b) to generate the wrong query with multiple ON DUPLICATE KEY
6856
Properties props = new Properties();
6857
props.put("rewriteBatchedStatements","true");
6858
props.put("useServerPrepStmts","false");
6859
props.put("enablePacketDebug","true");
6860
this.conn = getConnectionWithProps(props);
6861
this.stmt = this.conn.createStatement();
6864
createTable("testbug12565726", "(id int primary key, txt1 varchar(32))");
6865
this.stmt.executeUpdate("INSERT INTO testbug12565726 " +
6866
"(id, txt1) VALUES (1, 'something')");
6869
this.pstmt = this.conn.prepareStatement("INSERT INTO " +
6870
"testbug12565726 (id, txt1) " +
6871
"VALUES (?, ?)ON DUPLICATE KEY UPDATE " +
6872
"id=LAST_INSERT_ID(id)+10");
6874
this.pstmt.setInt(1, 1);
6875
this.pstmt.setString(2, "something else");
6876
this.pstmt.addBatch();
6878
this.pstmt.setInt(1, 2);
6879
this.pstmt.setString(2, "hope it is not error again!");
6880
this.pstmt.addBatch();
6882
this.pstmt.executeBatch();
6889
public void testBug36478() throws Exception {
6891
createTable("testBug36478", "(`limit` varchar(255) not null primary key, id_limit INT, limit1 INT, maxlimit2 INT)");
6893
this.stmt.execute("INSERT INTO testBug36478 VALUES ('bahblah',1,1,1)");
6894
this.stmt.execute("INSERT INTO testBug36478 VALUES ('bahblah2',2,2,2)");
6895
this.pstmt = this.conn.prepareStatement("select 1 FROM testBug36478");
6897
this.pstmt.setMaxRows(1);
6898
this.rs = this.pstmt.executeQuery();
6900
assertTrue(this.rs.isFirst());
6901
assertTrue(this.rs.isLast());
6903
this.pstmt = this.conn.prepareStatement("select `limit`, id_limit, limit1, maxlimit2 FROM testBug36478");
6904
this.pstmt.setMaxRows(0);
6905
this.rs = this.pstmt.executeQuery();
6907
assertTrue(this.rs.isFirst());
6908
assertFalse(this.rs.isLast());
6911
Connection _conn = null;
6912
PreparedStatement s = null;
6914
Properties props = new Properties();
6915
props.setProperty("useServerPrepStmts", "true");
6917
_conn = getConnectionWithProps(props);
6918
s = _conn.prepareStatement("select 1 FROM testBug36478");
6921
ResultSet _rs = s.executeQuery();
6923
assertTrue(_rs.isFirst());
6924
assertTrue(_rs.isLast());
6926
s = _conn.prepareStatement("select `limit`, id_limit, limit1, maxlimit2 FROM testBug36478");
6928
_rs = s.executeQuery();
6930
assertTrue(_rs.isFirst());
6931
assertFalse(_rs.isLast());
6937
if (_conn != null) {
6945
* Tests fix for BUG#40279 - Timestamp values get truncated when passed as prepared statement parameters
6946
* (and duplicate BUG#60584 - prepared statements truncate milliseconds)
6948
* [13 Sep 2012 21:06] Mark Matthews
6949
* This was fixed with http://bazaar.launchpad.net/~mysql/connectorj/5.1/revision/1107 in 2011,
6950
* it supports MySQL-5.6.4 or later.
6952
* But that fix did not cover useLegacyDatetimeCode=true case.
6956
public void testBug40279() throws Exception {
6957
if (!versionMeetsMinimum(5, 6, 4)) {
6961
createTable("testBug40279", "(f1 int, f2 timestamp(6))");
6963
Timestamp ts = new Timestamp(1300791248001L);
6965
Connection ps_conn_legacy = null;
6966
Connection ps_conn_nolegacy = null;
6968
Connection ssps_conn_legacy = null;
6969
Connection ssps_conn_nolegacy = null;
6972
Properties props = new Properties();
6973
props.setProperty("serverTimezone", "UTC");
6974
props.setProperty("useLegacyDatetimeCode", "true");
6975
props.setProperty("useServerPrepStmts", "false");
6976
ps_conn_legacy = getConnectionWithProps(props);
6978
props.setProperty("useLegacyDatetimeCode", "false");
6979
ps_conn_nolegacy = getConnectionWithProps(props);
6981
props.setProperty("useLegacyDatetimeCode", "true");
6982
props.setProperty("useServerPrepStmts", "true");
6983
ssps_conn_legacy = getConnectionWithProps(props);
6985
props.setProperty("useLegacyDatetimeCode", "false");
6986
ssps_conn_nolegacy = getConnectionWithProps(props);
6988
this.pstmt = ps_conn_legacy.prepareStatement("INSERT INTO testBug40279(f1, f2) VALUES (?, ?)");
6989
this.pstmt.setInt(1, 1);
6990
this.pstmt.setTimestamp(2, ts);
6991
this.pstmt.execute();
6994
this.pstmt = ps_conn_nolegacy.prepareStatement("INSERT INTO testBug40279(f1, f2) VALUES (?, ?)");
6995
this.pstmt.setInt(1, 2);
6996
this.pstmt.setTimestamp(2, ts);
6997
this.pstmt.execute();
7000
this.pstmt = ssps_conn_legacy.prepareStatement("INSERT INTO testBug40279(f1, f2) VALUES (?, ?)");
7001
this.pstmt.setInt(1, 3);
7002
this.pstmt.setTimestamp(2, ts);
7003
this.pstmt.execute();
7006
this.pstmt = ssps_conn_nolegacy.prepareStatement("INSERT INTO testBug40279(f1, f2) VALUES (?, ?)");
7007
this.pstmt.setInt(1, 4);
7008
this.pstmt.setTimestamp(2, ts);
7009
this.pstmt.execute();
7012
this.rs = this.stmt.executeQuery("SELECT f2 FROM testBug40279");
7013
while (this.rs.next()) {
7014
assertEquals(ts.getNanos(), this.rs.getTimestamp("f2").getNanos());
7018
if (ps_conn_legacy != null) {
7019
ps_conn_legacy.close();
7021
if (ps_conn_nolegacy != null) {
7022
ps_conn_nolegacy.close();
7024
if (ssps_conn_legacy != null) {
7025
ssps_conn_legacy.close();
7027
if (ssps_conn_nolegacy != null) {
7028
ssps_conn_nolegacy.close();
7035
* Tests fix for BUG#35653 - executeQuery() in Statement.java let "TRUNCATE" queries being executed.
7036
* "RENAME" is also filtered now.
7040
public void testBug35653() throws Exception {
7041
createTable("testBug35653", "(f1 int)");
7043
this.stmt.executeQuery("TRUNCATE testBug35653");
7044
fail("executeQuery() shouldn't allow TRUNCATE");
7045
} catch (SQLException e) {
7046
assertTrue(SQLError.SQL_STATE_ILLEGAL_ARGUMENT == e.getSQLState());
7050
this.stmt.executeQuery("RENAME TABLE testBug35653 TO testBug35653_new");
7051
fail("executeQuery() shouldn't allow RENAME");
7052
} catch (SQLException e) {
7053
assertTrue(SQLError.SQL_STATE_ILLEGAL_ARGUMENT == e.getSQLState());
7055
dropTable("testBug35653_new");
7060
* Tests fix for BUG#64805 - StatementImpl$CancelTask occasionally throws NullPointerExceptions.
7064
public void testBug64805() throws Exception {
7067
this.stmt.setQueryTimeout(5);
7068
this.stmt.executeQuery("select sleep(5)");
7069
} catch (NullPointerException e) {
7070
e.printStackTrace();
7072
} catch (Exception e) {
7073
if (e instanceof MySQLTimeoutException) {
7074
// expected behavior in slow environment