本文整理汇总了Java中com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource.setURL方法的典型用法代码示例。如果您正苦于以下问题:Java MysqlConnectionPoolDataSource.setURL方法的具体用法?Java MysqlConnectionPoolDataSource.setURL怎么用?Java MysqlConnectionPoolDataSource.setURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
的用法示例。
在下文中一共展示了MysqlConnectionPoolDataSource.setURL方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpMySqlResource
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* example code to setup Mysql resource for JNDI lookup by JPA
* implementation (EclipseLink here) You may follow this model for
* registering Database resources, you also have to expose your resource's
* related jars to the server classpath in the maven pom file (checkout the
* execution with id 'jetty-classpath' in this project's pom.xml file).
*/
private static void setUpMySqlResource() {
try {
MysqlConnectionPoolDataSource dataPool = new MysqlConnectionPoolDataSource();
dataPool.setURL(conf.getProperty("url"));
dataPool.setUser(conf.getProperty("user"));
dataPool.setPassword(conf.getProperty("password"));
if (conf.getProperty("DB_useSSL").equalsIgnoreCase("true")) {
dataPool.setUseSSL(true);
dataPool.setRequireSSL(true);
System.setProperty("javax.net.ssl.trustStore", conf.getProperty("keystorePath"));
System.setProperty("javax.net.ssl.trustStorePassword", conf.getProperty("keystorePass"));
// debugging ssl connection ...
// System.setProperty("javax.net.debug", "all");
}
new Resource(null, "jdbc/conName", dataPool);
} catch (NamingException ex) {
// unlikely
logger.info("Error setting up Mysql resource \n" + ex);
}
}
示例2: setUp
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Set up test case before a test is run.
*
* @throws Exception
*/
@Override
public void setUp() throws Exception {
super.setUp();
// Reset event count.
this.closeEventCount = 0;
this.connectionErrorEventCount = 0;
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
this.cpds = ds;
}
示例3: testBug4808
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Tests fix for BUG#4808- Calling .close() twice on a PooledConnection
* causes NPE.
*
* @throws Exception
* if an error occurs.
*/
public void testBug4808() throws Exception {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
PooledConnection closeMeTwice = ds.getPooledConnection();
closeMeTwice.close();
closeMeTwice.close();
}
示例4: testBug32101
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Tests fix for BUG#32101 - When using a connection from our ConnectionPoolDataSource,
* some Connection.prepareStatement() methods would return null instead of
* a prepared statement.
*
* @throws Exception
*/
public void testBug32101() throws Exception {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
PooledConnection pc = ds.getPooledConnection();
assertNotNull(pc.getConnection().prepareStatement("SELECT 1"));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", Statement.RETURN_GENERATED_KEYS));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new int[0]));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new String[0]));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
assertNotNull(
pc.getConnection().prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT));
}
示例5: testBug32101
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Tests fix for BUG#32101 - When using a connection from our ConnectionPoolDataSource,
* some Connection.prepareStatement() methods would return null instead of
* a prepared statement.
*
* @throws Exception
*/
public void testBug32101() throws Exception {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
PooledConnection pc = ds.getPooledConnection();
assertNotNull(pc.getConnection().prepareStatement("SELECT 1"));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", Statement.RETURN_GENERATED_KEYS));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new int[0]));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new String[0]));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
ResultSet.HOLD_CURSORS_OVER_COMMIT));
}
示例6: setUp
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Set up test case before a test is run.
*
* @throws Exception
* DOCUMENT ME!
*/
public void setUp() throws Exception {
super.setUp();
// Reset event count.
this.closeEventCount = 0;
this.connectionErrorEventCount = 0;
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
this.cpds = ds;
}
示例7: testBug4808
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Tests fix for BUG#4808- Calling .close() twice on a PooledConnection
* causes NPE.
*
* @throws Exception
* if an error occurs.
*/
public void testBug4808() throws Exception {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
PooledConnection closeMeTwice = ds.getPooledConnection();
closeMeTwice.close();
closeMeTwice.close();
}
示例8: testBug32101
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Tests fix for BUG#32101 - When using a connection from our ConnectionPoolDataSource,
* some Connection.prepareStatement() methods would return null instead of
* a prepared statement.
*
* @throws Exception
*/
public void testBug32101() throws Exception {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
PooledConnection pc = ds.getPooledConnection();
assertNotNull(pc.getConnection().prepareStatement("SELECT 1"));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", Statement.RETURN_GENERATED_KEYS));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new int[0]));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new String[0]));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
assertNotNull(pc.getConnection().prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT));
}
示例9: testChangeUserAndCharsets
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Tests whether Connection.changeUser() (and thus pooled connections)
* restore character set information correctly.
*
* @throws Exception
* if the test fails.
*/
public void testChangeUserAndCharsets() throws Exception {
if (versionMeetsMinimum(4, 1)) {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
ds.setCharacterEncoding("utf-8");
PooledConnection pooledConnection = ds.getPooledConnection();
Connection connToMySQL = pooledConnection.getConnection();
this.rs = connToMySQL.createStatement().executeQuery("SELECT @@character_set_results");
assertTrue(this.rs.next());
String toCheck = null;
if (versionMeetsMinimum(4, 1, 15)) {
if (versionMeetsMinimum(5, 0)) {
if (versionMeetsMinimum(5, 0, 13)) {
toCheck = null;
} else {
toCheck = "NULL";
}
} else {
toCheck = null;
}
} else {
toCheck = "NULL";
}
assertEquals(toCheck, this.rs.getString(1));
this.rs = connToMySQL.createStatement().executeQuery("SHOW SESSION VARIABLES LIKE 'character_set_client'");
assertTrue(this.rs.next());
//Cause of utf8mb4
assertEquals(0, this.rs.getString(2).indexOf("utf8"));
connToMySQL.close();
connToMySQL = pooledConnection.getConnection();
this.rs = connToMySQL.createStatement().executeQuery("SELECT @@character_set_results");
assertTrue(this.rs.next());
assertEquals(toCheck, this.rs.getString(1));
this.rs = connToMySQL.createStatement().executeQuery("SHOW SESSION VARIABLES LIKE 'character_set_client'");
assertTrue(this.rs.next());
//Cause of utf8mb4
assertEquals(0, this.rs.getString(2).indexOf("utf8"));
pooledConnection.getConnection().close();
}
}
示例10: testChangeUserAndCharsets
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; //导入方法依赖的package包/类
/**
* Tests whether Connection.changeUser() (and thus pooled connections)
* restore character set information correctly.
*
* @throws Exception
* if the test fails.
*/
public void testChangeUserAndCharsets() throws Exception {
if (versionMeetsMinimum(4, 1)) {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
ds.setCharacterEncoding("utf-8");
PooledConnection pooledConnection = ds.getPooledConnection();
Connection connToMySQL = pooledConnection.getConnection();
this.rs = connToMySQL.createStatement().executeQuery(
"SELECT @@character_set_results");
assertTrue(this.rs.next());
String toCheck = null;
if (versionMeetsMinimum(4, 1, 15)) {
if (versionMeetsMinimum(5, 0)) {
if (versionMeetsMinimum(5, 0, 13)) {
toCheck = null;
} else {
toCheck = "NULL";
}
} else {
toCheck = null;
}
} else {
toCheck = "NULL";
}
assertEquals(toCheck, this.rs.getString(1));
this.rs = connToMySQL.createStatement().executeQuery(
"SHOW SESSION VARIABLES LIKE 'character_set_client'");
assertTrue(this.rs.next());
//Cause of utf8mb4
assertEquals(0, this.rs.getString(2).indexOf("utf8"));
connToMySQL.close();
connToMySQL = pooledConnection.getConnection();
this.rs = connToMySQL.createStatement().executeQuery(
"SELECT @@character_set_results");
assertTrue(this.rs.next());
assertEquals(toCheck, this.rs.getString(1));
this.rs = connToMySQL.createStatement().executeQuery(
"SHOW SESSION VARIABLES LIKE 'character_set_client'");
assertTrue(this.rs.next());
//Cause of utf8mb4
assertEquals(0, this.rs.getString(2).indexOf("utf8"));
pooledConnection.getConnection().close();
}
}