use of org.h2.engine.User in project h2database by h2database.
the class JdbcDatabaseMetaData method getUDTs.
/**
* Gets the list of user-defined data types.
* This call returns an empty result set.
*
* <ol>
* <li>TYPE_CAT (String) catalog</li>
* <li>TYPE_SCHEM (String) schema</li>
* <li>TYPE_NAME (String) type name</li>
* <li>CLASS_NAME (String) Java class</li>
* <li>DATA_TYPE (short) SQL Type - see also java.sql.Types</li>
* <li>REMARKS (String) description</li>
* <li>BASE_TYPE (short) base type - see also java.sql.Types</li>
* </ol>
*
* @param catalog ignored
* @param schemaPattern ignored
* @param typeNamePattern ignored
* @param types ignored
* @return an empty result set
* @throws SQLException if the connection is closed
*/
@Override
public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("getUDTs(" + quote(catalog) + ", " + quote(schemaPattern) + ", " + quote(typeNamePattern) + ", " + quoteIntArray(types) + ");");
}
checkClosed();
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "CAST(NULL AS VARCHAR) TYPE_CAT, " + "CAST(NULL AS VARCHAR) TYPE_SCHEM, " + "CAST(NULL AS VARCHAR) TYPE_NAME, " + "CAST(NULL AS VARCHAR) CLASS_NAME, " + "CAST(NULL AS SMALLINT) DATA_TYPE, " + "CAST(NULL AS VARCHAR) REMARKS, " + "CAST(NULL AS SMALLINT) BASE_TYPE " + "FROM DUAL WHERE FALSE");
return prep.executeQuery();
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.engine.User in project h2database by h2database.
the class JdbcDataSource method getJdbcConnection.
private JdbcConnection getJdbcConnection(String user, char[] password) throws SQLException {
if (isDebugEnabled()) {
debugCode("getJdbcConnection(" + quote(user) + ", new char[0]);");
}
Properties info = new Properties();
info.setProperty("user", user);
info.put("password", password);
Connection conn = Driver.load().connect(url, info);
if (conn == null) {
throw new SQLException("No suitable driver found for " + url, "08001", 8001);
} else if (!(conn instanceof JdbcConnection)) {
throw new SQLException("Connecting with old version is not supported: " + url, "08001", 8001);
}
return (JdbcConnection) conn;
}
use of org.h2.engine.User in project h2database by h2database.
the class TestConnectionPool method testShutdown.
private void testShutdown() throws SQLException {
String url = getURL("connectionPool2", true), user = getUser();
String password = getPassword();
JdbcConnectionPool cp = JdbcConnectionPool.create(url, user, password);
StringWriter w = new StringWriter();
cp.setLogWriter(new PrintWriter(w));
Connection conn1 = cp.getConnection();
Connection conn2 = cp.getConnection();
conn1.close();
conn2.createStatement().execute("shutdown immediately");
cp.dispose();
assertTrue(w.toString().length() > 0);
cp.dispose();
}
use of org.h2.engine.User in project h2database by h2database.
the class TestConnectionPool method testUncommittedTransaction.
private void testUncommittedTransaction() throws SQLException {
String url = getURL("connectionPool", true), user = getUser();
String password = getPassword();
JdbcConnectionPool man = JdbcConnectionPool.create(url, user, password);
assertEquals(30, man.getLoginTimeout());
man.setLoginTimeout(1);
assertEquals(1, man.getLoginTimeout());
man.setLoginTimeout(0);
assertEquals(30, man.getLoginTimeout());
assertEquals(10, man.getMaxConnections());
PrintWriter old = man.getLogWriter();
PrintWriter pw = new PrintWriter(new StringWriter());
man.setLogWriter(pw);
assertTrue(pw == man.getLogWriter());
man.setLogWriter(old);
Connection conn1 = man.getConnection();
assertTrue(conn1.getAutoCommit());
conn1.setAutoCommit(false);
conn1.close();
assertTrue(conn1.isClosed());
Connection conn2 = man.getConnection();
assertTrue(conn2.getAutoCommit());
conn2.close();
man.dispose();
}
use of org.h2.engine.User in project h2database by h2database.
the class TestConnectionPool method testPerformance.
private void testPerformance() throws SQLException {
String url = getURL("connectionPool", true), user = getUser();
String password = getPassword();
JdbcConnectionPool man = JdbcConnectionPool.create(url, user, password);
Connection conn = man.getConnection();
int len = 1000;
long time = System.nanoTime();
for (int i = 0; i < len; i++) {
man.getConnection().close();
}
man.dispose();
trace((int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - time));
time = System.nanoTime();
for (int i = 0; i < len; i++) {
DriverManager.getConnection(url, user, password).close();
}
trace((int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - time));
conn.close();
}
Aggregations