本文整理匯總了Java中com.mysql.jdbc.jdbc2.optional.MysqlDataSource.setPort方法的典型用法代碼示例。如果您正苦於以下問題:Java MysqlDataSource.setPort方法的具體用法?Java MysqlDataSource.setPort怎麽用?Java MysqlDataSource.setPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.mysql.jdbc.jdbc2.optional.MysqlDataSource
的用法示例。
在下文中一共展示了MysqlDataSource.setPort方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; //導入方法依賴的package包/類
public void init() throws SQLException, RuleBaseException, TeEngineMlException, ParserRunException
{
ruleBaseName = "origdirt";
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setServerName("qa-srv");
dataSource.setPort(3308);
dataSource.setUser("db_readonly");
//dataSource.setPassword("");
distSimConnection = dataSource.getConnection();
DistSimParameters originalDirtParameters =
new DistSimParameters("original_dirt.od_templates", "original_dirt.od_rules", LIMIT_DISTSIM_RULES, 2*Constants.DEFAULT_DIRT_LIKE_RESOURCES_CACHE_SIZE, Constants.DEFAULT_DIRT_LIKE_RESOURCES_CACHE_SIZE);
ruleBase = new DistSimRuleBase(distSimConnection,originalDirtParameters,ruleBaseName,parserMode);
parser = ParserFactory.getParser(miniparParameter);
}
示例2: getDataSource
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; //導入方法依賴的package包/類
public static DataSource getDataSource(
String hostName,
int port,
String username,
String passwordClear,
String databaseName)
{
if (hostName == null) { throw new IllegalArgumentException("hostName cannot be null"); }
if (username == null) { throw new IllegalArgumentException("username cannot be null"); }
if (passwordClear == null) { throw new IllegalArgumentException("passwordClear cannot be null"); }
if (databaseName == null) { throw new IllegalArgumentException("databaseName cannot be null"); }
MysqlDataSource ds = new MysqlDataSource();
ds.setServerName(hostName);
ds.setPort(port);
ds.setUser(username);
ds.setPassword(passwordClear);
ds.setDatabaseName(databaseName);
return ds;
}
示例3: getAntiExploitConnection
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; //導入方法依賴的package包/類
private Connection getAntiExploitConnection() {
try {
MysqlDataSource mySqlDataSource = new MysqlDataSource();
mySqlDataSource.setDatabaseName(AntiExploit.getInstance().getConfiguration().getConfig().getDatabase());
mySqlDataSource.setUser(AntiExploit.getInstance().getConfiguration().getConfig().getUsername());
mySqlDataSource.setPassword(AntiExploit.getInstance().getConfiguration().getConfig().getPassword());
mySqlDataSource.setServerName(AntiExploit.getInstance().getConfiguration().getConfig().getHost());
mySqlDataSource.setPort(AntiExploit.getInstance().getConfiguration().getConfig().getPort());
return mySqlDataSource.getConnection();
} catch (SQLException ex) {
AntiExploit.getInstance().getLogger().error("Failed to connect to MySQL database!");
ex.printStackTrace();
}
return null;
}
示例4: dropDatabase
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; //導入方法依賴的package包/類
public static void dropDatabase(
String hostName,
int port,
String username,
String passwordClear,
String databaseName)
{
if (hostName == null) { throw new IllegalArgumentException("hostName cannot be null"); }
if (username == null) { throw new IllegalArgumentException("username cannot be null"); }
if (passwordClear == null) { throw new IllegalArgumentException("passwordClear cannot be null"); }
if (databaseName == null) { throw new IllegalArgumentException("databaseName cannot be null"); }
MysqlDataSource rootDs = new MysqlDataSource();
rootDs.setServerName(hostName);
rootDs.setPort(port);
rootDs.setUser(username);
rootDs.setPassword(passwordClear);
rootDs.setDatabaseName("mysql");
try
{
DatabaseHelper.execute(rootDs, String.format("DROP DATABASE `%s`;", databaseName));
}
catch(SQLException e)
{
throw new RuntimeException(e);
}
}
示例5: getAdminDataSource
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; //導入方法依賴的package包/類
/**
* Returns a DataSource for the information schema in the target MySQL database.
*
* @return a DataSource for the information schema in the target MySQL server.
* @since 1.0
*/
@Override public DataSource getAdminDataSource()
{
MysqlDataSource ds = new MysqlDataSource();
ds.setServerName(this.getHostName());
ds.setPort(this.getPort());
ds.setUser(this.getAdminUsername());
ds.setPassword(this.getAdminPassword());
ds.setDatabaseName("information_schema");
return ds;
}
示例6: getAppDataSource
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; //導入方法依賴的package包/類
/**
* Returns a DataSource for the application schema that this instance represents, in the target MySQL server.
*
* @return a DataSource for the application schema in the target MySQL server.
* @since 1.0
*/
@Override public DataSource getAppDataSource()
{
MysqlDataSource ds = new MysqlDataSource();
ds.setServerName(this.getHostName());
ds.setPort(this.getPort());
ds.setUser(this.getAdminUsername());
ds.setPassword(this.getAdminPassword());
ds.setDatabaseName(this.getDatabaseName());
return ds;
}
示例7: getDataSource
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; //導入方法依賴的package包/類
/**
* wrap a datasource with a tomcat jdbc pool
* Connection con = null;
*
* TODO: implement FUTURE connections
* try {
* Future<Connection> future = datasource.getConnectionAsync();
* while (!future.isDone()) {
* System.out.println(
* "Connection is not yet available. Do some background work");
* try {
* Thread.sleep(100); //simulate work
* }catch (InterruptedException x) {
* Thread.currentThread().interrupt();
* }
* }
* con = future.get(); //should return instantly
* Statement st = con.createStatement();
* ResultSet rs = st.executeQuery("select * from user");
*
* @return
*/
public static DataSource getDataSource() {
MysqlDataSource ds = new MysqlDataSource();
org.apache.tomcat.jdbc.pool.DataSource dsx = new org.apache.tomcat.jdbc.pool.DataSource();
PoolProperties p = new PoolProperties();
if (System.getProperty("PARAM1") != null
&& System.getProperty("PARAM1").equalsIgnoreCase("production")) {
ds.setServerName(sourceURL);
ds.setPassword(password);
p.setUrl(sourceURL);
}else{
ds.setServerName(backupURL);
ds.setPassword(backupPassword);
p.setUrl(backupURL);
p.setPassword(backupPassword);
}
ds.setPort(sourcePort);
ds.setDatabaseName(dbName);
ds.setUser(userName);
p.setDriverClassName("com.mysql.jdbc.Driver");
p.setUsername(userName);
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(100);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
// wrap and allow for lazy queue fun
dsx.setPoolProperties(p);
dsx.setFairQueue(true);
dsx.setDataSource(ds);
return dsx;
}