Java Code Examples for com.mysql.jdbc.Connection

The following are top voted examples for showing how to use com.mysql.jdbc.Connection. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BibliotecaPS   File: ResultSetScannerInterceptor.java   Source Code and License 6 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    String regexFromUser = props.getProperty("resultSetScannerRegex");

    if (regexFromUser == null || regexFromUser.length() == 0) {
        throw new SQLException("resultSetScannerRegex must be configured, and must be > 0 characters");
    }

    try {
        this.regexP = Pattern.compile(regexFromUser);
    } catch (Throwable t) {
        SQLException sqlEx = new SQLException("Can't use configured regex due to underlying exception.");
        sqlEx.initCause(t);

        throw sqlEx;
    }

}
 
Example 2
Project: the-vigilantes   File: SessionAssociationInterceptor.java   Source Code and License 6 votes vote down vote up
public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement, Connection connection) throws SQLException {
    String key = getSessionKey();

    if (key != null && !key.equals(this.currentSessionKey)) {
        PreparedStatement pstmt = connection.clientPrepareStatement("SET @mysql_proxy_session=?");

        try {
            pstmt.setString(1, key);
            pstmt.execute();
        } finally {
            pstmt.close();
        }

        this.currentSessionKey = key;
    }

    return null;
}
 
Example 3
Project: the-vigilantes   File: ResultSetScannerInterceptor.java   Source Code and License 6 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    String regexFromUser = props.getProperty("resultSetScannerRegex");

    if (regexFromUser == null || regexFromUser.length() == 0) {
        throw new SQLException("resultSetScannerRegex must be configured, and must be > 0 characters");
    }

    try {
        this.regexP = Pattern.compile(regexFromUser);
    } catch (Throwable t) {
        SQLException sqlEx = new SQLException("Can't use configured regex due to underlying exception.");
        sqlEx.initCause(t);

        throw sqlEx;
    }

}
 
Example 4
Project: lams   File: SessionAssociationInterceptor.java   Source Code and License 6 votes vote down vote up
public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement, Connection connection) throws SQLException {
    String key = getSessionKey();

    if (key != null && !key.equals(this.currentSessionKey)) {
        PreparedStatement pstmt = connection.clientPrepareStatement("SET @mysql_proxy_session=?");

        try {
            pstmt.setString(1, key);
            pstmt.execute();
        } finally {
            pstmt.close();
        }

        this.currentSessionKey = key;
    }

    return null;
}
 
Example 5
Project: lams   File: ServerStatusDiffInterceptor.java   Source Code and License 6 votes vote down vote up
private void populateMapWithSessionStatusValues(Connection connection, Map<String, String> toPopulate) throws SQLException {
    java.sql.Statement stmt = null;
    java.sql.ResultSet rs = null;

    try {
        toPopulate.clear();

        stmt = connection.createStatement();
        rs = stmt.executeQuery("SHOW SESSION STATUS");
        Util.resultSetToMap(toPopulate, rs);
    } finally {
        if (rs != null) {
            rs.close();
        }

        if (stmt != null) {
            stmt.close();
        }
    }
}
 
Example 6
Project: lams   File: ResultSetScannerInterceptor.java   Source Code and License 6 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    String regexFromUser = props.getProperty("resultSetScannerRegex");

    if (regexFromUser == null || regexFromUser.length() == 0) {
        throw new SQLException("resultSetScannerRegex must be configured, and must be > 0 characters");
    }

    try {
        this.regexP = Pattern.compile(regexFromUser);
    } catch (Throwable t) {
        SQLException sqlEx = new SQLException("Can't use configured regex due to underlying exception.");
        sqlEx.initCause(t);

        throw sqlEx;
    }

}
 
Example 7
Project: FYS_T3   File: SqlConnection.java   Source Code and License 6 votes vote down vote up
public static Connection DbConnetor() {
    try {
        Class.forName("com.mysql.jdbc.Driver");
        conn = (Connection) DriverManager.getConnection(url, username, password);
        return conn;
    } catch (ClassNotFoundException | SQLException e) {
        System.err.println("exception!");
        System.err.println(e.getMessage());
    }
    return null;
}
 
Example 8
Project: OpenVertretung   File: ConnectionWrapper.java   Source Code and License 6 votes vote down vote up
protected static ConnectionWrapper getInstance(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException {
    if (!Util.isJdbc4()) {
        return new ConnectionWrapper(mysqlPooledConnection, mysqlConnection, forXa);
    }

    return (ConnectionWrapper) Util.handleNewInstance(JDBC_4_CONNECTION_WRAPPER_CTOR,
            new Object[] { mysqlPooledConnection, mysqlConnection, Boolean.valueOf(forXa) }, mysqlPooledConnection.getExceptionInterceptor());
}
 
Example 9
Project: ProyectoPacientes   File: ResultSetScannerInterceptor.java   Source Code and License 6 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    String regexFromUser = props.getProperty("resultSetScannerRegex");

    if (regexFromUser == null || regexFromUser.length() == 0) {
        throw new SQLException("resultSetScannerRegex must be configured, and must be > 0 characters");
    }

    try {
        this.regexP = Pattern.compile(regexFromUser);
    } catch (Throwable t) {
        SQLException sqlEx = new SQLException("Can't use configured regex due to underlying exception.");
        sqlEx.initCause(t);

        throw sqlEx;
    }

}
 
Example 10
Project: OpenVertretung   File: ResultSetScannerInterceptor.java   Source Code and License 6 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    String regexFromUser = props.getProperty("resultSetScannerRegex");

    if (regexFromUser == null || regexFromUser.length() == 0) {
        throw new SQLException("resultSetScannerRegex must be configured, and must be > 0 characters");
    }

    try {
        this.regexP = Pattern.compile(regexFromUser);
    } catch (Throwable t) {
        SQLException sqlEx = new SQLException("Can't use configured regex due to underlying exception.");
        sqlEx.initCause(t);

        throw sqlEx;
    }

}
 
Example 11
Project: InComb   File: UserLocalesService.java   Source Code and License 5 votes vote down vote up
/**
 * Returns a List of {@link Locale}s for the given user
 * @param userId of the user to get the locales from
 * @param con Connection to use - is injected automatically
 * @return a list of {@link Locale}s
 */
@GET
public Response getLocales(@PathParam("userId") final long userId, @Context final Connection con) {
	getAccessChecker().checkLoggedInUser(userId);
	final List<Locale> locales = new UserLocaleDao(con).getLocalesForUser(userId);
	return ok(locales);
}
 
Example 12
Project: ProyectoPacientes   File: Sha256PasswordPlugin.java   Source Code and License 5 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    this.connection = conn;

    String pkURL = this.connection.getServerRSAPublicKeyFile();
    if (pkURL != null) {
        this.publicKeyString = readRSAKey(this.connection, pkURL);
    }
}
 
Example 13
Project: ProyectoPacientes   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized java.sql.Connection getConnection() throws SQLException {
    if (this.currentXAConnection == null) {
        return getConnection(false, true);
    }

    return this.currentXAConnection.getConnection();
}
 
Example 14
Project: lams   File: Sha256PasswordPlugin.java   Source Code and License 5 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    this.connection = conn;

    String pkURL = this.connection.getServerRSAPublicKeyFile();
    if (pkURL != null) {
        this.publicKeyString = readRSAKey(this.connection, pkURL);
    }
}
 
Example 15
Project: lams   File: ServerStatusDiffInterceptor.java   Source Code and License 5 votes vote down vote up
public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement, Connection connection) throws SQLException {

        if (connection.versionMeetsMinimum(5, 0, 2)) {
            populateMapWithSessionStatusValues(connection, this.preExecuteValues);
        }

        return null; // we don't actually modify a result set
    }
 
Example 16
Project: the-vigilantes   File: FabricMySQLConnectionProxy.java   Source Code and License 5 votes vote down vote up
protected Connection getActiveConnectionPassive() {
    try {
        return getActiveConnection();
    } catch (SQLException ex) {
        throw new IllegalStateException("Unable to determine active connection", ex);
    }
}
 
Example 17
Project: sierra   File: MySqlUtilsTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testSelectAll() throws SQLException {
	String testSql = "SELECT * FROM Sequence";

	JdbcDatabase db = spy(new JdbcDatabase(null, null, null));
	Connection conn = mock(Connection.class);
	doReturn(conn).when(db).getConnection();
	PreparedStatement stmt = mock(PreparedStatement.class);
	when(conn.prepareStatement(any(String.class))).thenReturn(stmt);

	db.selectAll(testSql, rs -> null);
	verify(conn, times(1)).prepareStatement(testSql);
}
 
Example 18
Project: ProyectoPacientes   File: Sha256PasswordPlugin.java   Source Code and License 5 votes vote down vote up
private static byte[] encryptPassword(String password, String seed, Connection connection, String key) throws SQLException {
    byte[] input = null;
    try {
        input = password != null ? StringUtils.getBytesNullTerminated(password, connection.getPasswordCharacterEncoding()) : new byte[] { 0 };
    } catch (UnsupportedEncodingException e) {
        throw SQLError.createSQLException(Messages.getString("Sha256PasswordPlugin.3", new Object[] { connection.getPasswordCharacterEncoding() }),
                SQLError.SQL_STATE_GENERAL_ERROR, null);
    }
    byte[] mysqlScrambleBuff = new byte[input.length];
    Security.xorString(input, mysqlScrambleBuff, seed.getBytes(), input.length);
    return ExportControlled.encryptWithRSAPublicKey(mysqlScrambleBuff,
            ExportControlled.decodeRSAPublicKey(key, ((MySQLConnection) connection).getExceptionInterceptor()),
            ((MySQLConnection) connection).getExceptionInterceptor());
}
 
Example 19
Project: FYS_T3   File: searchLugController.java   Source Code and License 5 votes vote down vote up
public void checkConnection() {
    conn = (Connection) SqlConnection.DbConnetor();
    if (conn == null) {
        System.out.println("Connection not successfull");
        System.exit(1);
    } else {
        System.out.println("Connection successfull");
    }

}
 
Example 20
Project: ProyectoPacientes   File: FabricMySQLConnectionProxy.java   Source Code and License 5 votes vote down vote up
/**
 * Close this connection proxy which entails closing all
 * open connections to MySQL servers.
 */
public void close() throws SQLException {
    this.closed = true;
    for (Connection c : this.serverConnections.values()) {
        try {
            c.close();
        } catch (SQLException ex) {
        }
    }
}
 
Example 21
Project: lams   File: FabricMySQLConnectionProxy.java   Source Code and License 5 votes vote down vote up
/**
 * Close this connection proxy which entails closing all
 * open connections to MySQL servers.
 */
public void close() throws SQLException {
    this.closed = true;
    for (Connection c : this.serverConnections.values()) {
        try {
            c.close();
        } catch (SQLException ex) {
        }
    }
}
 
Example 22
Project: the-vigilantes   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
protected static SuspendableXAConnection getInstance(Connection mysqlConnection) throws SQLException {
    if (!Util.isJdbc4()) {
        return new SuspendableXAConnection(mysqlConnection);
    }

    return (SuspendableXAConnection) Util.handleNewInstance(JDBC_4_XA_CONNECTION_WRAPPER_CTOR, new Object[] { mysqlConnection },
            mysqlConnection.getExceptionInterceptor());
}
 
Example 23
Project: ProyectoPacientes   File: ErrorReportingExceptionInterceptor.java   Source Code and License 5 votes vote down vote up
public SQLException interceptException(SQLException sqlEx, Connection conn) {
    MySQLConnection mysqlConn = (MySQLConnection) conn;

    // don't intercept exceptions during initialization, before the proxy has a chance to setProxy() on the physical connection
    if (ConnectionImpl.class.isAssignableFrom(mysqlConn.getMultiHostSafeProxy().getClass())) {
        return null;
    }

    FabricMySQLConnectionProxy fabricProxy = (FabricMySQLConnectionProxy) mysqlConn.getMultiHostSafeProxy();
    try {
        return fabricProxy.interceptException(sqlEx, conn, this.fabricHaGroup, this.hostname, this.port);
    } catch (FabricCommunicationException ex) {
        return SQLError.createSQLException("Failed to report error to Fabric.", SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE, ex, null);
    }
}
 
Example 24
Project: the-vigilantes   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
private static synchronized XAConnection findConnectionForXid(Connection connectionToWrap, Xid xid) throws SQLException {
    // TODO: check for same GTRID, but different BQUALs...MySQL doesn't allow this yet

    // Note, we don't need to check for XIDs here, because MySQL itself will complain with a XAER_NOTA if need be.

    XAConnection conn = XIDS_TO_PHYSICAL_CONNECTIONS.get(xid);

    if (conn == null) {
        conn = new MysqlXAConnection(connectionToWrap, connectionToWrap.getLogXaCommands());
        XIDS_TO_PHYSICAL_CONNECTIONS.put(xid, conn);
    }

    return conn;
}
 
Example 25
Project: the-vigilantes   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized java.sql.Connection getConnection() throws SQLException {
    if (this.currentXAConnection == null) {
        return getConnection(false, true);
    }

    return this.currentXAConnection.getConnection();
}
 
Example 26
Project: lams   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized java.sql.Connection getConnection() throws SQLException {
    if (this.currentXAConnection == null) {
        return getConnection(false, true);
    }

    return this.currentXAConnection.getConnection();
}
 
Example 27
Project: the-vigilantes   File: ResultSetScannerInterceptor.java   Source Code and License 5 votes vote down vote up
public ResultSetInternalMethods postProcess(String sql, Statement interceptedStatement, ResultSetInternalMethods originalResultSet, Connection connection)
        throws SQLException {

    // requirement of anonymous class
    final ResultSetInternalMethods finalResultSet = originalResultSet;

    return (ResultSetInternalMethods) Proxy.newProxyInstance(originalResultSet.getClass().getClassLoader(), new Class[] { ResultSetInternalMethods.class },
            new InvocationHandler() {

                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                    if ("equals".equals(method.getName())) {
                        // Let args[0] "unwrap" to its InvocationHandler if it is a proxy.
                        return args[0].equals(this);
                    }

                    Object invocationResult = method.invoke(finalResultSet, args);

                    String methodName = method.getName();

                    if (invocationResult != null && invocationResult instanceof String || "getString".equals(methodName) || "getObject".equals(methodName)
                            || "getObjectStoredProc".equals(methodName)) {
                        Matcher matcher = ResultSetScannerInterceptor.this.regexP.matcher(invocationResult.toString());

                        if (matcher.matches()) {
                            throw new SQLException("value disallowed by filter");
                        }
                    }

                    return invocationResult;
                }
            });

}
 
Example 28
Project: the-vigilantes   File: ServerStatusDiffInterceptor.java   Source Code and License 5 votes vote down vote up
public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement, Connection connection) throws SQLException {

        if (connection.versionMeetsMinimum(5, 0, 2)) {
            populateMapWithSessionStatusValues(connection, this.preExecuteValues);
        }

        return null; // we don't actually modify a result set
    }
 
Example 29
Project: lams   File: ConnectionWrapper.java   Source Code and License 5 votes vote down vote up
/**
 * Construct a new LogicalHandle and set instance variables
 * 
 * @param mysqlPooledConnection
 *            reference to object that instantiated this object
 * @param mysqlConnection
 *            physical connection to db
 * 
 * @throws SQLException
 *             if an error occurs.
 */
public ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException {
    super(mysqlPooledConnection);

    this.mc = mysqlConnection;
    this.closed = false;
    this.isForXa = forXa;

    if (this.isForXa) {
        setInGlobalTx(false);
    }
}
 
Example 30
Project: lams   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
private static synchronized XAConnection findConnectionForXid(Connection connectionToWrap, Xid xid) throws SQLException {
    // TODO: check for same GTRID, but different BQUALs...MySQL doesn't allow this yet

    // Note, we don't need to check for XIDs here, because MySQL itself will complain with a XAER_NOTA if need be.

    XAConnection conn = XIDS_TO_PHYSICAL_CONNECTIONS.get(xid);

    if (conn == null) {
        conn = new MysqlXAConnection(connectionToWrap, connectionToWrap.getLogXaCommands());
        XIDS_TO_PHYSICAL_CONNECTIONS.put(xid, conn);
    }

    return conn;
}
 
Example 31
Project: OpenVertretung   File: FabricMySQLConnectionProxy.java   Source Code and License 5 votes vote down vote up
protected Connection getActiveConnectionPassive() {
    try {
        return getActiveConnection();
    } catch (SQLException ex) {
        throw new IllegalStateException("Unable to determine active connection", ex);
    }
}
 
Example 32
Project: BibliotecaPS   File: FabricMySQLConnectionProxy.java   Source Code and License 5 votes vote down vote up
/**
 * Close this connection proxy which entails closing all
 * open connections to MySQL servers.
 */
public void close() throws SQLException {
    this.closed = true;
    for (Connection c : this.serverConnections.values()) {
        try {
            c.close();
        } catch (SQLException ex) {
        }
    }
}
 
Example 33
Project: BibliotecaPS   File: ServerStatusDiffInterceptor.java   Source Code and License 5 votes vote down vote up
public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement, Connection connection) throws SQLException {

        if (connection.versionMeetsMinimum(5, 0, 2)) {
            populateMapWithSessionStatusValues(connection, this.preExecuteValues);
        }

        return null; // we don't actually modify a result set
    }
 
Example 34
Project: ProyectoPacientes   File: ConnectionWrapper.java   Source Code and License 5 votes vote down vote up
/**
 * Construct a new LogicalHandle and set instance variables
 * 
 * @param mysqlPooledConnection
 *            reference to object that instantiated this object
 * @param mysqlConnection
 *            physical connection to db
 * 
 * @throws SQLException
 *             if an error occurs.
 */
public ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException {
    super(mysqlPooledConnection);

    this.mc = mysqlConnection;
    this.closed = false;
    this.isForXa = forXa;

    if (this.isForXa) {
        setInGlobalTx(false);
    }
}
 
Example 35
Project: OpenVertretung   File: ErrorReportingExceptionInterceptor.java   Source Code and License 5 votes vote down vote up
public SQLException interceptException(SQLException sqlEx, Connection conn) {
    MySQLConnection mysqlConn = (MySQLConnection) conn;

    // don't intercept exceptions during initialization, before the proxy has a chance to setProxy() on the physical connection
    if (ConnectionImpl.class.isAssignableFrom(mysqlConn.getMultiHostSafeProxy().getClass())) {
        return null;
    }

    FabricMySQLConnectionProxy fabricProxy = (FabricMySQLConnectionProxy) mysqlConn.getMultiHostSafeProxy();
    try {
        return fabricProxy.interceptException(sqlEx, conn, this.fabricHaGroup, this.hostname, this.port);
    } catch (FabricCommunicationException ex) {
        return SQLError.createSQLException("Failed to report error to Fabric.", SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE, ex, null);
    }
}
 
Example 36
Project: BibliotecaPS   File: FabricMySQLConnectionProxy.java   Source Code and License 5 votes vote down vote up
protected Connection getActiveConnectionPassive() {
    try {
        return getActiveConnection();
    } catch (SQLException ex) {
        throw new IllegalStateException("Unable to determine active connection", ex);
    }
}
 
Example 37
Project: BibliotecaPS   File: ConnectionWrapper.java   Source Code and License 5 votes vote down vote up
/**
 * Construct a new LogicalHandle and set instance variables
 * 
 * @param mysqlPooledConnection
 *            reference to object that instantiated this object
 * @param mysqlConnection
 *            physical connection to db
 * 
 * @throws SQLException
 *             if an error occurs.
 */
public ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException {
    super(mysqlPooledConnection);

    this.mc = mysqlConnection;
    this.closed = false;
    this.isForXa = forXa;

    if (this.isForXa) {
        setInGlobalTx(false);
    }
}
 
Example 38
Project: OpenVertretung   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
protected static SuspendableXAConnection getInstance(Connection mysqlConnection) throws SQLException {
    if (!Util.isJdbc4()) {
        return new SuspendableXAConnection(mysqlConnection);
    }

    return (SuspendableXAConnection) Util.handleNewInstance(JDBC_4_XA_CONNECTION_WRAPPER_CTOR, new Object[] { mysqlConnection },
            mysqlConnection.getExceptionInterceptor());
}
 
Example 39
Project: lams   File: ConnectionWrapper.java   Source Code and License 5 votes vote down vote up
protected static ConnectionWrapper getInstance(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException {
    if (!Util.isJdbc4()) {
        return new ConnectionWrapper(mysqlPooledConnection, mysqlConnection, forXa);
    }

    return (ConnectionWrapper) Util.handleNewInstance(JDBC_4_CONNECTION_WRAPPER_CTOR,
            new Object[] { mysqlPooledConnection, mysqlConnection, Boolean.valueOf(forXa) }, mysqlPooledConnection.getExceptionInterceptor());
}
 
Example 40
Project: OpenVertretung   File: SuspendableXAConnection.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized java.sql.Connection getConnection() throws SQLException {
    if (this.currentXAConnection == null) {
        return getConnection(false, true);
    }

    return this.currentXAConnection.getConnection();
}
 
Example 41
Project: OpenVertretung   File: ConnectionWrapper.java   Source Code and License 5 votes vote down vote up
/**
 * Construct a new LogicalHandle and set instance variables
 * 
 * @param mysqlPooledConnection
 *            reference to object that instantiated this object
 * @param mysqlConnection
 *            physical connection to db
 * 
 * @throws SQLException
 *             if an error occurs.
 */
public ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException {
    super(mysqlPooledConnection);

    this.mc = mysqlConnection;
    this.closed = false;
    this.isForXa = forXa;

    if (this.isForXa) {
        setInGlobalTx(false);
    }
}
 
Example 42
Project: FYS_T3   File: submitController.java   Source Code and License 5 votes vote down vote up
/**
 * METHODS
 *
 * @author Shabier Jagoori
 */
public void checkConnection() {
    conn = (Connection) SqlConnection.DbConnetor();
    if (conn == null) {
        System.out.println("Connection not successfull");
        System.exit(1);
    } else {
        System.out.println("Connection successfull");
    }

}
 
Example 43
Project: lams   File: FabricMySQLConnectionProxy.java   Source Code and License 5 votes vote down vote up
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
    for (Connection c : this.serverConnections.values()) {
        c.setTypeMap(map);
    }
}
 
Example 44
Project: OpenVertretung   File: ServerStatusDiffInterceptor.java   Source Code and License 5 votes vote down vote up
public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement, Connection connection) throws SQLException {

        if (connection.versionMeetsMinimum(5, 0, 2)) {
            populateMapWithSessionStatusValues(connection, this.preExecuteValues);
        }

        return null; // we don't actually modify a result set
    }
 
Example 45
Project: lams   File: ConnectionWrapper.java   Source Code and License 4 votes vote down vote up
public boolean isSameResource(com.mysql.jdbc.Connection c) {
    if (c instanceof ConnectionWrapper) {
        return this.mc.isSameResource(((ConnectionWrapper) c).mc);
    }
    return this.mc.isSameResource(c);
}
 
Example 46
Project: the-vigilantes   File: BaseStatementInterceptor.java   Source Code and License 4 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
}
 
Example 47
Project: BibliotecaPS   File: FabricMySQLConnectionProxy.java   Source Code and License 4 votes vote down vote up
public void setTransactionIsolation(int level) throws SQLException {
    this.transactionIsolation = level;
    for (Connection c : this.serverConnections.values()) {
        c.setTransactionIsolation(level);
    }
}
 
Example 48
Project: the-vigilantes   File: BaseStatementInterceptor.java   Source Code and License 4 votes vote down vote up
public ResultSetInternalMethods postProcess(String sql, Statement interceptedStatement, ResultSetInternalMethods originalResultSet, Connection connection,
        int warningCount, boolean noIndexUsed, boolean noGoodIndexUsed, SQLException statementException) throws SQLException {
    return originalResultSet;
}
 
Example 49
Project: ProyectoPacientes   File: LoggingProfilerEventHandler.java   Source Code and License 4 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    this.log = conn.getLog();
}
 
Example 50
Project: the-vigilantes   File: FabricMySQLConnectionProxy.java   Source Code and License 4 votes vote down vote up
protected Connection getActiveConnection() throws SQLException {
    if (!this.transactionInProgress) {
        refreshStateIfNecessary();
    }

    if (this.currentConnection != null) {
        return this.currentConnection;
    }

    if (getCurrentServerGroup() == null) {
        throw SQLError.createSQLException("No server group selected.", SQLError.SQL_STATE_CONNECTION_REJECTED, null, getExceptionInterceptor(), this);
    }

    // try to find an existing replication connection to the current group
    this.currentConnection = this.serverConnections.get(this.serverGroup);
    if (this.currentConnection != null) {
        return this.currentConnection;
    }

    // otherwise, build a replication connection to the current group
    List<String> masterHost = new ArrayList<String>();
    List<String> slaveHosts = new ArrayList<String>();
    for (Server s : this.serverGroup.getServers()) {
        if (s.isMaster()) {
            masterHost.add(s.getHostPortString());
        } else if (s.isSlave()) {
            slaveHosts.add(s.getHostPortString());
        }
    }
    Properties info = exposeAsProperties(null);
    ReplicationConnectionGroup replConnGroup = ReplicationConnectionGroupManager.getConnectionGroup(this.serverGroup.getName());
    if (replConnGroup != null) {
        if (replConnGroupLocks.add(this.serverGroup.getName())) {
            try {
                syncGroupServersToReplicationConnectionGroup(replConnGroup);
            } finally {
                replConnGroupLocks.remove(this.serverGroup.getName());
            }
        }
    }
    info.put("replicationConnectionGroup", this.serverGroup.getName());
    info.setProperty(NonRegisteringDriver.USER_PROPERTY_KEY, this.username);
    info.setProperty(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password);
    info.setProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY, getCatalog());
    info.setProperty("connectionAttributes", "fabricHaGroup:" + this.serverGroup.getName());
    info.setProperty("retriesAllDown", "1");
    info.setProperty("allowMasterDownConnections", "true");
    info.setProperty("allowSlaveDownConnections", "true");
    info.setProperty("readFromMasterWhenNoSlaves", "true");
    this.currentConnection = ReplicationConnectionProxy.createProxyInstance(masterHost, info, slaveHosts, info);
    this.serverConnections.put(this.serverGroup, this.currentConnection);

    this.currentConnection.setProxy(this);
    this.currentConnection.setAutoCommit(this.autoCommit);
    this.currentConnection.setReadOnly(this.readOnly);
    this.currentConnection.setTransactionIsolation(this.transactionIsolation);
    return this.currentConnection;
}
 
Example 51
Project: the-vigilantes   File: FabricMySQLConnectionProxy.java   Source Code and License 4 votes vote down vote up
public void setCatalog(String catalog) throws SQLException {
    this.database = catalog;
    for (Connection c : this.serverConnections.values()) {
        c.setCatalog(catalog);
    }
}
 
Example 52
Project: ProyectoPacientes   File: MysqlClearPasswordPlugin.java   Source Code and License 4 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    this.connection = conn;
}
 
Example 53
Project: BibliotecaPS   File: ConnectionWrapper.java   Source Code and License 4 votes vote down vote up
public boolean hasSameProperties(Connection c) {
    return this.mc.hasSameProperties(c);
}
 
Example 54
Project: ProyectoPacientes   File: JDBC4SuspendableXAConnection.java   Source Code and License 4 votes vote down vote up
public JDBC4SuspendableXAConnection(Connection connection) throws SQLException {
    super(connection);
}
 
Example 55
Project: the-vigilantes   File: FabricMySQLConnectionProxy.java   Source Code and License 4 votes vote down vote up
public boolean isSameResource(Connection c) {
    return false;
}
 
Example 56
Project: BibliotecaPS   File: JDBC4FabricMySQLConnectionProxy.java   Source Code and License 4 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    for (Connection c : serverConnections.values())
        c.setClientInfo(properties);
}
 
Example 57
Project: ProyectoPacientes   File: BaseStatementInterceptor.java   Source Code and License 4 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
}
 
Example 58
Project: the-vigilantes   File: MysqlOldPasswordPlugin.java   Source Code and License 4 votes vote down vote up
public void init(Connection conn, Properties props) throws SQLException {
    this.connection = conn;
}
 
Example 59
Project: BibliotecaPS   File: BaseStatementInterceptor.java   Source Code and License 4 votes vote down vote up
public ResultSetInternalMethods postProcess(String sql, Statement interceptedStatement, ResultSetInternalMethods originalResultSet, Connection connection,
        int warningCount, boolean noIndexUsed, boolean noGoodIndexUsed, SQLException statementException) throws SQLException {
    return originalResultSet;
}
 
Example 60
Project: lams   File: ResultSetScannerInterceptor.java   Source Code and License 4 votes vote down vote up
public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement, Connection connection) throws SQLException {
    // we don't care about this event

    return null;
}