|
|
|
@ -13,9 +13,10 @@ import javax.sql.DataSource;
|
|
|
|
|
|
|
|
|
|
public class DataBaseManager
|
|
|
|
|
{
|
|
|
|
|
private static DataBaseManager instance;
|
|
|
|
|
private DataSource dataSource1;
|
|
|
|
|
private DataSource dataSource2;
|
|
|
|
|
private static DataBaseManager instance = null;
|
|
|
|
|
private DataSource dataSource1 = null;
|
|
|
|
|
private DataSource dataSource2 = null;
|
|
|
|
|
private DataSource dataSource3 = null;
|
|
|
|
|
|
|
|
|
|
// private DataSource dataSource;
|
|
|
|
|
|
|
|
|
@ -33,6 +34,7 @@ public class DataBaseManager
|
|
|
|
|
{
|
|
|
|
|
dataSource1 = (DataSource) ctx.lookup("mysql1");
|
|
|
|
|
dataSource2 = (DataSource) ctx.lookup("mysql2");
|
|
|
|
|
dataSource3 = (DataSource) ctx.lookup("mysql3");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (NamingException e)
|
|
|
|
@ -72,6 +74,17 @@ public class DataBaseManager
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public final Connection getConnection3()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return dataSource3.getConnection();
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw new RuntimeException("无法从数据源获取连接 database3", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void TestConn1() throws SQLException
|
|
|
|
|
{
|
|
|
|
|