Commit 686ace2b authored by Aigul Baimussayeva's avatar Aigul Baimussayeva

application with db

parent 13bb6ac0
......@@ -32,6 +32,8 @@ dependencies {
providedCompile 'org.apache.httpcomponents:httpclient:4.5'
compile "commons-io:commons-io:2.1"
compile group: 'com.google.guava', name: 'guava-gwt', version: '18.0'
compile ('org.jboss.spec:jboss-javaee-6.0:3.0.3.Final')
providedCompile group: 'org.jboss.resteasy', name: 'resteasy-jaxrs', version: '2.3.3.Final'
}
......
......@@ -2,6 +2,7 @@ package kz.arta.test.blocking;
import kz.arta.test.blocking.data.ASFData;
import kz.arta.test.blocking.data.ASFDataWrapperExt;
import kz.arta.test.blocking.mysql.ArtaMysqlConnectionPool;
import kz.arta.test.blocking.utils.AsfDataApi;
import kz.arta.test.blocking.utils.DictApi;
import kz.arta.test.blocking.utils.PropsUtil;
......@@ -16,6 +17,9 @@ import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* User: Aigul
......@@ -76,6 +80,17 @@ public class BlockProcessListener implements MessageListener {
asfDataApi.saveData(REGULAR_MAPPER.writeValueAsString(data.getData()), data.getForm(), data.getUuid(), null);
}
/*тут пример с БД*/
try (Connection con = ArtaMysqlConnectionPool.getXAConnection()){
PreparedStatement ps = con.prepareStatement("INSERT INTO docs_opened(documentID, userID, date) VALUES(?,?,CURRENT_TIMESTAMP )");
ps.setString(1, "docID");
ps.setString(2, "userID");
ps.execute();
} catch (SQLException e) {
LOGGER.error(e.getMessage(), e);
}
} catch (Exception exc) {
LOGGER.error("Error processing text message", exc);
} finally {
......
package kz.arta.test.blocking;
import kz.arta.test.blocking.mysql.ArtaMysqlConnectionPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.sql.Connection;
import java.sql.PreparedStatement;
@Path("/")
public class ITSMRestService {
private static final Logger LOGGER = LoggerFactory.getLogger(ITSMRestService.class);
@GET
@Path("/close")
@Produces(MediaType.TEXT_PLAIN + "; charset=utf-8")
public Response rate(@QueryParam("documentID") String documentID, @QueryParam("userID") String userID) {
try (Connection con = ArtaMysqlConnectionPool.getXAConnection()) {
PreparedStatement ps = con.prepareStatement("DELETE FROM docs_opened WHERE documentID = ? and userID = ?");
ps.setString(1, documentID);
ps.setString(2, userID);
ps.execute();
return Response.ok("Doc deleted").build();
} catch (Exception e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Error while doc deleting").build();
}
}
}
package kz.arta.test.blocking.mysql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
/**
* Поток проверки соединений mysql arta-synergy
*
* @author MGetmanov
* @since 28.05.15 8:43
*/
public class ArtaMysqlCheckConnThread extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(ArtaMysqlCheckConnThread.class);
private StackTraceElement[] elements;
private Connection con = null;
private static boolean isEnabled = false;
private static long timeout = 0;
private static boolean closeConnections = false;
static {
if (ArtaMysqlConfigManager.getProps().containsKey(ArtaMysqlConfigManager.ConfigKeyProperties.observe_connections.name()) &&
DataExtractorCommon.getBoolean(ArtaMysqlConfigManager.getProps().get(ArtaMysqlConfigManager.ConfigKeyProperties.observe_connections.name()))) {
isEnabled = true;
timeout = DataExtractorCommon.getLongStat(ArtaMysqlConfigManager.getProps().get(ArtaMysqlConfigManager.ConfigKeyProperties.observe_connection_timeout.name()));
closeConnections = DataExtractorCommon.getBoolean(ArtaMysqlConfigManager.getProps().get(ArtaMysqlConfigManager.ConfigKeyProperties.close_observing_connection.name()));
if (timeout < 180000) {
timeout = 180000;
}
}
LOGGER.info("Observing opened connections is " + (isEnabled ? "enabled" : "disabled"));
if (isEnabled) {
LOGGER.info("Started observing connections with parameters: timeout=" + timeout + "ms; close_connections=" + closeConnections);
if (closeConnections) {
LOGGER.error("WARNING! Closing connections in production mode is a VERY BAD IDEA. If you really need to do this " +
"contact developers.");
}
}
}
private ArtaMysqlCheckConnThread(StackTraceElement[] elements, Connection con) {
this.elements = elements;
this.con = con;
}
@Override
public void run() {
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
}
try {
if (con != null && !con.isClosed()) {
StringBuilder str = new StringBuilder();
for (StackTraceElement element : elements) {
str.append("\n\t");
str.append(element.toString());
}
LOGGER.error("Connection was not closed within allowed timeout [" + timeout + "] !" + str.toString());
if (closeConnections) {
LOGGER.error("Closing connection for you");
try {
con.close();
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
}
}
}
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
}
}
public static void startObserveConnection(Connection con) {
if (!isEnabled) {
return;
}
new ArtaMysqlCheckConnThread(Thread.currentThread().getStackTrace(), con).start();
}
}
\ No newline at end of file
package kz.arta.test.blocking.mysql;
/**
* Поля по умолчанию для менеджера конфигурации mysql соединений arta-synergy
*
* @author MGetmanov
* @since 28.05.15 8:40
*/
interface ArtaMysqlConfigDefaultFields {
}
package kz.arta.test.blocking.mysql;
import java.util.Properties;
/**
* Менеджер конфигурации работы с MYSQL для arta-synergy
*
* @author MGetmanov
* @since 28.05.15 8:39
*/
public class ArtaMysqlConfigManager {
public static DbConfig config;
public enum ConfigKeyProperties {
observe_connections,
observe_connection_timeout,
close_observing_connection
}
public synchronized static Properties getProps() {
return getConfig().getProps();
}
private synchronized static DbConfig getConfig() {
if (config == null) {
config = new DbConfig();
config.initialize();
}
return config;
}
public static String getEarName() {
return getConfig().getEarName();
}
public static String getCfgURL() {
return getConfig().getCfgURL();
}
public static String getCfgDirectory() {
return getConfig().getCfgDirectory();
}
public static String getSynergyDS() {
return getConfig().getSynergyDS();
}
public static String getConfFilePath(String relativePath) {
return getConfig().getConfFilePath(relativePath);
}
}
package kz.arta.test.blocking.mysql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
/**
* Класс предназначен для управления соединениями с базой данных
* Для получения соединения необходимо использовать метод getXAConnection
* Для закрытия соединения необходимо использовать метод closeConnection
* User: topa
* Date: 15.07.2008
* Time: 12:34:40
*/
public class ArtaMysqlConnectionPool {
private static final Logger LOGGER = LoggerFactory.getLogger(ArtaMysqlConnectionPool.class);
private static final String POOL_NAME = "java:/SynergyItsm";
/**
* Метод для получения соединения из пула
*
* @return - открытое соединение
*/
public static Connection getXAConnection() {
Connection con = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup(POOL_NAME);
con = ds.getConnection();
ArtaMysqlCheckConnThread.startObserveConnection(con);
return new ConnectionImpl(con);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
closeConnection(con);
throw new IllegalStateException(e);
}
}
/**
* Метод для закрытия соединения
*
* @param con - соединение которое необходимо закрыть
*/
public static void closeConnection(Connection con) {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
}
package kz.arta.test.blocking.mysql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
/**
* Created by exile
* Date: 18.06.15
* Time: 13:51
* класс обертка для соединения, который собирает все открытые стейтменты и закрывает их
*/
public class ConnectionImpl implements Connection {
private static final Logger LOGGER = LoggerFactory.getLogger(ArtaMysqlConnectionPool.class);
private Connection connection;
private List<Statement> statements = new ArrayList<>();
public ConnectionImpl(Connection connection) {
this.connection = connection;
}
@Override
public void close() throws SQLException {
for (Statement st : statements) {
try {
st.close();
} catch (SQLException e) {
LOGGER.error(e.getMessage(), e);
}
}
connection.close();
statements = null;
connection = null;
}
private Statement statementOpened(Statement st){
statements.add(st);
return new StatementImpl(st, this);
}
private PreparedStatement statementOpened(PreparedStatement st) {
statements.add(st);
return new PreparedStatementImpl(st, this);
}
private CallableStatement statementOpened(CallableStatement st) {
statements.add(st);
return new CallableStatementImpl(st, this);
}
public void setAutoCommit(boolean autoCommit) throws SQLException {
connection.setAutoCommit(autoCommit);
}
public boolean getAutoCommit() throws SQLException {
return connection.getAutoCommit();
}
public PreparedStatement prepareStatement(String sql) throws SQLException {
PreparedStatement st = connection.prepareStatement(sql);
return statementOpened(st);
}
public Statement createStatement() throws SQLException {
Statement st = connection.createStatement();
return statementOpened(st);
}
public void commit() throws SQLException {
if (!connection.getAutoCommit()) {
connection.commit();
}
}
public void rollback() throws SQLException {
connection.rollback();
}
public boolean isClosed() throws SQLException {
return connection.isClosed();
}
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
Statement st = connection.createStatement(resultSetType, resultSetConcurrency);
return statementOpened(st);
}
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
PreparedStatement st = connection.prepareStatement(sql, resultSetType, resultSetConcurrency);
return statementOpened(st);
}
public Savepoint setSavepoint(String name) throws SQLException {
return connection.setSavepoint(name);
}
public Savepoint setSavepoint() throws SQLException {
return connection.setSavepoint();
}
public void rollback(Savepoint savepoint) throws SQLException {
connection.rollback(savepoint);
}
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
connection.releaseSavepoint(savepoint);
}
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
PreparedStatement st = connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
return statementOpened(st);
}
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
Statement st = connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
return statementOpened(st);
}
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
PreparedStatement st = connection.prepareStatement(sql, autoGeneratedKeys);
return statementOpened(st);
}
public PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException {
PreparedStatement st = connection.prepareStatement(sql, columnNames);
return statementOpened(st);
}
public PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException {
PreparedStatement st = connection.prepareStatement(sql, columnIndexes);
return statementOpened(st);
}
public CallableStatement prepareCall(String sql) throws SQLException {
return connection.prepareCall(sql);
}
public String nativeSQL(String sql) throws SQLException {
return connection.nativeSQL(sql);
}
public DatabaseMetaData getMetaData() throws SQLException {
return connection.getMetaData();
}
public void setReadOnly(boolean readOnly) throws SQLException {
connection.setReadOnly(readOnly);
}
public boolean isReadOnly() throws SQLException {
return connection.isReadOnly();
}
public void setCatalog(String catalog) throws SQLException {
connection.setCatalog(catalog);
}
public String getCatalog() throws SQLException {
return connection.getCatalog();
}
public void setTransactionIsolation(int level) throws SQLException {
connection.setTransactionIsolation(level);
}
public int getTransactionIsolation() throws SQLException {
return connection.getTransactionIsolation();
}
public SQLWarning getWarnings() throws SQLException {
return connection.getWarnings();
}
public void clearWarnings() throws SQLException {
connection.clearWarnings();
}
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
return connection.prepareCall(sql, resultSetType, resultSetConcurrency);
}
public Map<String, Class<?>> getTypeMap() throws SQLException {
return connection.getTypeMap();
}
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
connection.setTypeMap(map);
}
public void setHoldability(int holdability) throws SQLException {
connection.setHoldability(holdability);
}
public int getHoldability() throws SQLException {
return connection.getHoldability();
}
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
CallableStatement st = connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
return statementOpened(st);
}
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
return connection.createArrayOf(typeName, elements);
}
public Clob createClob() throws SQLException {
return connection.createClob();
}
public Blob createBlob() throws SQLException {
return connection.createBlob();
}
public NClob createNClob() throws SQLException {
return connection.createNClob();
}
public SQLXML createSQLXML() throws SQLException {
return connection.createSQLXML();
}
public boolean isValid(int timeout) throws SQLException {
return connection.isValid(timeout);
}
public void setClientInfo(String name, String value) throws SQLClientInfoException {
connection.setClientInfo(name, value);
}
public void setClientInfo(Properties properties) throws SQLClientInfoException {
connection.setClientInfo(properties);
}
public String getClientInfo(String name) throws SQLException {
return connection.getClientInfo(name);
}
public Properties getClientInfo() throws SQLException {
return connection.getClientInfo();
}
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
return connection.createStruct(typeName, attributes);
}
public <T> T unwrap(Class<T> iFace) throws SQLException {
return connection.unwrap(iFace);
}
public boolean isWrapperFor(Class<?> iFace) throws SQLException {
return connection.isWrapperFor(iFace);
}
public void setSchema(String schema) throws SQLException {
connection.setSchema(schema);
}
public String getSchema() throws SQLException {
return connection.getSchema();
}
public void abort(Executor executor) throws SQLException {
connection.abort(executor);
}
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
connection.setNetworkTimeout(executor, milliseconds);
}
public int getNetworkTimeout() throws SQLException {
return connection.getNetworkTimeout();
}
}
package kz.arta.test.blocking.mysql;
/**
* Извлекатель данных из объектов
*
* @author MGetmanov
* @since 28.05.15 8:44
*/
class DataExtractorCommon {
public static Long getLongStat(Object obj) {
if (obj == null) {
return 0l;
}
try {
return new Long(obj.toString());
} catch (Exception e) {
return 0l;
}
}
public static Boolean getBoolean(Object obj) {
if (obj == null) {
return false;
}
try {
if (Boolean.parseBoolean(obj.toString()) || (obj + "").equalsIgnoreCase("true") || (obj + "").equals("1")) {
return true;
}
} catch (Exception ignored) {
}
return false;
}
}
package kz.arta.test.blocking.mysql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DbConfig {
private static Logger LOGGER = LoggerFactory.getLogger(ArtaMysqlConfigManager.class);
private static final String DEFAULT_EAR_NAME = "Synergy";
private String ear_name = "Synergy";
private Properties props = new Properties();
public DbConfig() {
}
public Properties getProps() {
return props;
}
public void initialize() {
String cfgFolder = getCfgURL();
LOGGER.info("JBoss cfg directory is " + cfgFolder + ". Trying read settings from it");
try {
File file = new File(getConfFilePath("arta/management/db.properties"));
if (file.exists()) {
FileInputStream fis = new FileInputStream(file);
props.load(fis);
fis.close();
} else {
throw new RuntimeException("File " + file.getAbsolutePath() + " does not exist!");
}
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
LOGGER.error("Failed to read settings from " + cfgFolder);
}
try {
if (ear_name != null && ear_name.length() > 0) {
LOGGER.debug("Going to read jcr mapped resource name");
}
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
}
}
/**
* Инициализация кэша очередей для документов
*/
private void initDocExents() {
final String docQueue = "java:jboss/exported/jms/queue/DocIndex";
final Collection<String> queue = new HashSet<String>();
queue.add(docQueue);
}
public String getEarName() {
String classLoader = Thread.currentThread().getContextClassLoader().toString();
Pattern p = Pattern.compile("(?:deployment.)([A-Za-z0-9_-[.]]+)(.ear)");
Matcher m = p.matcher(classLoader);
if (m.find()) {
return m.group(1);
} else {
return "";
}
}
public String getCfgURL() {
//For JBoss AS5
String cfgDir = System.getProperty("jboss.server.config.url");
//For JBoss AS7
if (cfgDir == null) {
cfgDir = System.getProperty("jboss.server.config.dir");
if (cfgDir != null) {
cfgDir = "file://" + cfgDir;
} else {
//If nothing helps
cfgDir = "file:///home/topa/services/jboss/server/default/conf";
}
}
return cfgDir;
}
public String getCfgDirectory() {
//For JBoss AS5
String cfgDir = System.getProperty("jboss.server.config.url");
if (cfgDir != null && cfgDir.startsWith("file://")) {
try {
URL url = new URL(cfgDir);
return url.getFile();
} catch (MalformedURLException e) {
LOGGER.error(e.getMessage(), e);
}
}
//For JBoss AS7
if (cfgDir == null) {
cfgDir = System.getProperty("jboss.server.config.dir");
if (cfgDir != null) {
return cfgDir;
} else {
//If nothing helps
return "/home/topa/services/jboss/server/default/conf";
}
}
return cfgDir;
}
public String getSynergyDS() {
if (ear_name.equals(DEFAULT_EAR_NAME)) {
return "java:/SynergyDS";
}
return "java:jboss/datasources/" + ear_name + "/synergy";
}
public String getConfFilePath(String relativePath) {
if (ear_name == null || ear_name.equals(DEFAULT_EAR_NAME))
return getCfgDirectory() + "/" + relativePath;
return getCfgDirectory() + "/" + ear_name + "/" + relativePath;
}
}
package kz.arta.test.blocking.mysql;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
/**
* User: vsl
* Date: 8/25/16
* Time: 12:52 PM
*/
public class PreparedStatementImpl extends StatementImpl implements PreparedStatement {
private PreparedStatement jdbcStatement;
public PreparedStatementImpl(PreparedStatement jdbcStatement, ConnectionImpl connectionWrapper) {
super(jdbcStatement, connectionWrapper);
this.jdbcStatement = jdbcStatement;
}
@Override
protected PreparedStatement getJdbcStatement() {
return jdbcStatement;
}
@Override
public ResultSet executeQuery() throws SQLException {
return getJdbcStatement().executeQuery();
}
@Override
public int executeUpdate() throws SQLException {
return getJdbcStatement().executeUpdate();
}
@Override
public void setNull(int parameterIndex, int sqlType) throws SQLException {
getJdbcStatement().setNull(parameterIndex, sqlType);
}
@Override
public void setBoolean(int parameterIndex, boolean x) throws SQLException {
getJdbcStatement().setBoolean(parameterIndex, x);
}
@Override
public void setByte(int parameterIndex, byte x) throws SQLException {
getJdbcStatement().setByte(parameterIndex, x);
}
@Override
public void setShort(int parameterIndex, short x) throws SQLException {
getJdbcStatement().setShort(parameterIndex, x);
}
@Override
public void setInt(int parameterIndex, int x) throws SQLException {
getJdbcStatement().setInt(parameterIndex, x);
}
@Override
public void setLong(int parameterIndex, long x) throws SQLException {
getJdbcStatement().setLong(parameterIndex, x);
}
@Override
public void setFloat(int parameterIndex, float x) throws SQLException {
getJdbcStatement().setFloat(parameterIndex, x);
}
@Override
public void setDouble(int parameterIndex, double x) throws SQLException {
getJdbcStatement().setDouble(parameterIndex, x);
}
@Override
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
getJdbcStatement().setBigDecimal(parameterIndex, x);
}
@Override
public void setString(int parameterIndex, String x) throws SQLException {
getJdbcStatement().setString(parameterIndex, x);
}
@Override
public void setBytes(int parameterIndex, byte[] x) throws SQLException {
getJdbcStatement().setBytes(parameterIndex, x);
}
@Override
public void setDate(int parameterIndex, Date x) throws SQLException {
getJdbcStatement().setDate(parameterIndex, x);
}
@Override
public void setTime(int parameterIndex, Time x) throws SQLException {
getJdbcStatement().setTime(parameterIndex, x);
}
@Override
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
getJdbcStatement().setTimestamp(parameterIndex, x);
}
@Override
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
getJdbcStatement().setAsciiStream(parameterIndex, x, length);
}
@Override
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
getJdbcStatement().setUnicodeStream(parameterIndex, x, length);
}
@Override
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
getJdbcStatement().setBinaryStream(parameterIndex, x, length);
}
@Override
public void clearParameters() throws SQLException {
getJdbcStatement().clearParameters();
}
@Override
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
getJdbcStatement().setObject(parameterIndex, x, targetSqlType);
}
@Override
public void setObject(int parameterIndex, Object x) throws SQLException {
getJdbcStatement().setObject(parameterIndex, x);
}
@Override
public boolean execute() throws SQLException {
return getJdbcStatement().execute();
}
@Override
public void addBatch() throws SQLException {
getJdbcStatement().addBatch();
}
@Override
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
getJdbcStatement().setCharacterStream(parameterIndex, reader, length);
}
@Override
public void setRef(int parameterIndex, Ref x) throws SQLException {
getJdbcStatement().setRef(parameterIndex, x);
}
@Override
public void setBlob(int parameterIndex, Blob x) throws SQLException {
getJdbcStatement().setBlob(parameterIndex, x);
}
@Override
public void setClob(int parameterIndex, Clob x) throws SQLException {
getJdbcStatement().setClob(parameterIndex, x);
}
@Override
public void setArray(int parameterIndex, Array x) throws SQLException {
getJdbcStatement().setArray(parameterIndex, x);
}
@Override
public ResultSetMetaData getMetaData() throws SQLException {
return getJdbcStatement().getMetaData();
}
@Override
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
getJdbcStatement().setDate(parameterIndex, x, cal);
}
@Override
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
getJdbcStatement().setTime(parameterIndex, x, cal);
}
@Override
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
getJdbcStatement().setTimestamp(parameterIndex, x, cal);
}
@Override
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
getJdbcStatement().setNull(parameterIndex, sqlType, typeName);
}
@Override
public void setURL(int parameterIndex, URL x) throws SQLException {
getJdbcStatement().setURL(parameterIndex, x);
}
@Override
public ParameterMetaData getParameterMetaData() throws SQLException {
return getJdbcStatement().getParameterMetaData();
}
@Override
public void setRowId(int parameterIndex, RowId x) throws SQLException {
getJdbcStatement().setRowId(parameterIndex, x);
}
@Override
public void setNString(int parameterIndex, String value) throws SQLException {
getJdbcStatement().setNString(parameterIndex, value);
}
@Override
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
getJdbcStatement().setNCharacterStream(parameterIndex, value, length);
}
@Override
public void setNClob(int parameterIndex, NClob value) throws SQLException {
getJdbcStatement().setNClob(parameterIndex, value);
}
@Override
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
getJdbcStatement().setClob(parameterIndex, reader, length);
}
@Override
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
getJdbcStatement().setBlob(parameterIndex, inputStream, length);
}
@Override
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
getJdbcStatement().setNClob(parameterIndex, reader, length);
}
@Override
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
getJdbcStatement().setSQLXML(parameterIndex, xmlObject);
}
@Override
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException {
getJdbcStatement().setObject(parameterIndex, x, targetSqlType, scaleOrLength);
}
@Override
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
getJdbcStatement().setAsciiStream(parameterIndex, x, length);
}
@Override
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
getJdbcStatement().setBinaryStream(parameterIndex, x, length);
}
@Override
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
getJdbcStatement().setCharacterStream(parameterIndex, reader, length);
}
@Override
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
getJdbcStatement().setAsciiStream(parameterIndex, x);
}
@Override
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
getJdbcStatement().setBinaryStream(parameterIndex, x);
}
@Override
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
getJdbcStatement().setCharacterStream(parameterIndex, reader);
}
@Override
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
getJdbcStatement().setNCharacterStream(parameterIndex, value);
}
@Override
public void setClob(int parameterIndex, Reader reader) throws SQLException {
getJdbcStatement().setClob(parameterIndex, reader);
}
@Override
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
getJdbcStatement().setBlob(parameterIndex, inputStream);
}
@Override
public void setNClob(int parameterIndex, Reader reader) throws SQLException {
getJdbcStatement().setNClob(parameterIndex, reader);
}
}
package kz.arta.test.blocking.mysql;
import java.sql.*;
/**
* User: vsl
* Date: 8/25/16
* Time: 11:51 AM
*/
public class StatementImpl implements Statement {
private Statement jdbcStatement;
protected ConnectionImpl connectionWrapper;
public StatementImpl(Statement jdbcStatement, ConnectionImpl connectionWrapper) {
this.jdbcStatement = jdbcStatement;
this.connectionWrapper = connectionWrapper;
}
protected Statement getJdbcStatement() {
return jdbcStatement;
}
@Override
public ResultSet executeQuery(String sql) throws SQLException {
return getJdbcStatement().executeQuery(sql);
}
@Override
public int executeUpdate(String sql) throws SQLException {
return getJdbcStatement().executeUpdate(sql);
}
@Override
public void close() throws SQLException {
getJdbcStatement().close();
}
@Override
public int getMaxFieldSize() throws SQLException {
return getJdbcStatement().getMaxFieldSize();
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
getJdbcStatement().setMaxFieldSize(max);
}
@Override
public int getMaxRows() throws SQLException {
return getJdbcStatement().getMaxRows();
}
@Override
public void setMaxRows(int max) throws SQLException {
getJdbcStatement().setMaxRows(max);
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
getJdbcStatement().setEscapeProcessing(enable);
}
@Override
public int getQueryTimeout() throws SQLException {
return getJdbcStatement().getQueryTimeout();
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
getJdbcStatement().setQueryTimeout(seconds);
}
@Override
public void cancel() throws SQLException {
getJdbcStatement().cancel();
}
@Override
public SQLWarning getWarnings() throws SQLException {
return getJdbcStatement().getWarnings();
}
@Override
public void clearWarnings() throws SQLException {
getJdbcStatement().clearWarnings();
}
@Override
public void setCursorName(String name) throws SQLException {
getJdbcStatement().setCursorName(name);
}
@Override
public boolean execute(String sql) throws SQLException {
return getJdbcStatement().execute(sql);
}
@Override
public ResultSet getResultSet() throws SQLException {
return getJdbcStatement().getResultSet();
}
@Override
public int getUpdateCount() throws SQLException {
return getJdbcStatement().getUpdateCount();
}
@Override
public boolean getMoreResults() throws SQLException {
return getJdbcStatement().getMoreResults();
}
@Override
public void setFetchDirection(int direction) throws SQLException {
getJdbcStatement().setFetchDirection(direction);
}
@Override
public int getFetchDirection() throws SQLException {
return getJdbcStatement().getFetchDirection();
}
@Override
public void setFetchSize(int rows) throws SQLException {
getJdbcStatement().setFetchSize(rows);
}
@Override
public int getFetchSize() throws SQLException {
return getJdbcStatement().getFetchSize();
}
@Override
public int getResultSetConcurrency() throws SQLException {
return getJdbcStatement().getResultSetConcurrency();
}
@Override
public int getResultSetType() throws SQLException {
return getJdbcStatement().getResultSetType();
}
@Override
public void addBatch(String sql) throws SQLException {
getJdbcStatement().addBatch(sql);
}
@Override
public void clearBatch() throws SQLException {
getJdbcStatement().clearBatch();
}
@Override
public int[] executeBatch() throws SQLException {
return getJdbcStatement().executeBatch();
}
@Override
public Connection getConnection() throws SQLException {
return connectionWrapper;
}
@Override
public boolean getMoreResults(int current) throws SQLException {
return getJdbcStatement().getMoreResults(current);
}
@Override
public ResultSet getGeneratedKeys() throws SQLException {
return getJdbcStatement().getGeneratedKeys();
}
@Override
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
return getJdbcStatement().executeUpdate(sql, autoGeneratedKeys);
}
@Override
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
return getJdbcStatement().executeUpdate(sql, columnIndexes);
}
@Override
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
return getJdbcStatement().executeUpdate(sql, columnNames);
}
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
return getJdbcStatement().execute(sql, autoGeneratedKeys);
}
@Override
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
return getJdbcStatement().execute(sql, columnIndexes);
}
@Override
public boolean execute(String sql, String[] columnNames) throws SQLException {
return getJdbcStatement().execute(sql, columnNames);
}
@Override
public int getResultSetHoldability() throws SQLException {
return getJdbcStatement().getResultSetHoldability();
}
@Override
public boolean isClosed() throws SQLException {
return getJdbcStatement().isClosed();
}
@Override
public void setPoolable(boolean poolable) throws SQLException {
getJdbcStatement().setPoolable(poolable);
}
@Override
public boolean isPoolable() throws SQLException {
return getJdbcStatement().isPoolable();
}
@Override
public void closeOnCompletion() throws SQLException {
getJdbcStatement().closeOnCompletion();
}
@Override
public boolean isCloseOnCompletion() throws SQLException {
return getJdbcStatement().isCloseOnCompletion();
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return getJdbcStatement().unwrap(iface);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return getJdbcStatement().isWrapperFor(iface);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment