AbstractStatement.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package org.elasticsearch.jdbc;
  2. import java.sql.*;
  3. public abstract class AbstractStatement extends AbstractFeatureNotSupportedStatement {
  4. private boolean isClosed = false;
  5. @Override
  6. public void close() throws SQLException {
  7. isClosed = true;
  8. }
  9. @Override
  10. public int getMaxFieldSize() throws SQLException {
  11. return 0;
  12. }
  13. @Override
  14. public void setMaxFieldSize(int max) throws SQLException {
  15. // ignore
  16. }
  17. @Override
  18. public int getMaxRows() throws SQLException {
  19. return 0;
  20. }
  21. @Override
  22. public void setMaxRows(int max) throws SQLException {
  23. // ignore
  24. }
  25. @Override
  26. public void setEscapeProcessing(boolean enable) throws SQLException {
  27. // ignore
  28. }
  29. @Override
  30. public int getQueryTimeout() throws SQLException {
  31. return 0;
  32. }
  33. @Override
  34. public void setQueryTimeout(int seconds) throws SQLException {
  35. // ignore
  36. }
  37. @Override
  38. public void cancel() throws SQLException {
  39. // ignore
  40. }
  41. @Override
  42. public SQLWarning getWarnings() throws SQLException {
  43. return null;
  44. }
  45. @Override
  46. public void clearWarnings() throws SQLException {
  47. }
  48. @Override
  49. public void setFetchSize(int rows) throws SQLException {
  50. // ignore
  51. }
  52. @Override
  53. public int getFetchSize() throws SQLException {
  54. return 0;
  55. }
  56. @Override
  57. public int getResultSetConcurrency() throws SQLException {
  58. return ResultSet.CONCUR_READ_ONLY;
  59. }
  60. @Override
  61. public int getResultSetType() throws SQLException {
  62. return ResultSet.TYPE_FORWARD_ONLY;
  63. }
  64. @Override
  65. public boolean getMoreResults(int current) throws SQLException {
  66. return false;
  67. }
  68. @Override
  69. public int getResultSetHoldability() throws SQLException {
  70. return ResultSet.CLOSE_CURSORS_AT_COMMIT;
  71. }
  72. @Override
  73. public boolean isClosed() throws SQLException {
  74. return isClosed;
  75. }
  76. @Override
  77. public void setPoolable(boolean poolable) throws SQLException {
  78. // ignore
  79. }
  80. @Override
  81. public boolean isPoolable() throws SQLException {
  82. return false;
  83. }
  84. @Override
  85. @SuppressWarnings("unchecked")
  86. public final <T> T unwrap(final Class<T> iface) throws SQLException {
  87. if (isWrapperFor(iface)) {
  88. return (T) this;
  89. }
  90. throw new SQLException(String.format("[%s] cannot be unwrapped as [%s]", getClass().getName(), iface.getName()));
  91. }
  92. @Override
  93. public final boolean isWrapperFor(final Class<?> iface) throws SQLException {
  94. return iface.isInstance(this);
  95. }
  96. }