Java Code Examples for java.sql.PreparedStatement.getConnection()

The following are Jave code examples for showing how to use getConnection() of the java.sql.PreparedStatement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: mark-framework   File:   Source Code and License Vote up 7 votes
public void setNonNullParameter(PreparedStatement ps, int i, Object[] parameter,
                                JdbcType jdbcType) throws SQLException {

    String typeName = null;
    if (parameter instanceof Integer[]) {
        typeName = TYPE_NAME_INTEGER;
    } else if (parameter instanceof String[]) {
        typeName = TYPE_NAME_VARCHAR;
    } else if (parameter instanceof Boolean[]) {
        typeName = TYPE_NAME_BOOLEAN;
    } else if (parameter instanceof Double[]) {
        typeName = TYPE_NAME_NUMERIC;

    if (typeName == null) {
        throw new TypeException("ArrayTypeHandler parameter typeName error, your type is " + parameter.getClass().getName());

    // 这3行是关键的代码,创建Array,然后ps.setArray(i, array)就可以了
    Connection conn = ps.getConnection();
    Array array = conn.createArrayOf(typeName, parameter);
    ps.setArray(i, array);
Example 2
Project: spanner-jdbc   File:   Source Code and License Vote up 6 votes
public void testPrepareStatement() throws SQLException
	CloudSpannerPooledConnection subject = createConnection();
	Connection connection = subject.getConnection();
	PreparedStatement statement = connection.prepareStatement("SELECT COL1, COL2, COL3 FROM FOO");

	Connection statementConnection = statement.getConnection();
	assertEquals(connection, statementConnection);

	assertEquals(ResultSet.TYPE_FORWARD_ONLY, statement.getResultSetType());
	catch (SQLException e)

Example 3
Project: SqlSauce   File:   Source Code and License Vote up 6 votes
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)
        throws HibernateException, SQLException {
    Connection connection = st.getConnection();

    if (value == null) {
        st.setNull(index, sqlTypes()[0]);
    } else {
        @SuppressWarnings("unchecked") ArrayList<Long> castObject = (ArrayList) value;

        Long[] longs = castObject.toArray(new Long[castObject.size()]);
        Array array = connection.createArrayOf("bigint", longs);

        st.setArray(index, array);
Example 4
Project: lams   File:   Source Code and License Vote up 5 votes
 * Retrieve the underlying OracleConnection, using a NativeJdbcExtractor if set.
protected Connection getOracleConnection(PreparedStatement ps)
		throws SQLException, ClassNotFoundException {

	return (nativeJdbcExtractor != null ?
			nativeJdbcExtractor.getNativeConnectionFromStatement(ps) : ps.getConnection());