|
|
|
|
@ -10,7 +10,18 @@
|
|
|
|
|
package db;
|
|
|
|
|
|
|
|
|
|
import com.evolute.application.initializer.DefaultDatabaseInitializer;
|
|
|
|
|
import com.evolute.entity.ProviderRegistry;
|
|
|
|
|
import com.evolute.entity.evo.EvoDataProviderFactory;
|
|
|
|
|
import com.evolute.entity.utils.ConnectionIdentity;
|
|
|
|
|
import com.evolute.utils.Singleton;
|
|
|
|
|
import com.evolute.utils.db.DBManager;
|
|
|
|
|
import com.evolute.utils.db.JDBCManager;
|
|
|
|
|
import com.evolute.utils.db.keyretrievers.PostgresqlAutoKeyRetriever;
|
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
|
|
import com.evolute.utils.jdbc.DBStatementExecuter;
|
|
|
|
|
import com.evolute.utils.jdbc.StatementExecuterFactory;
|
|
|
|
|
import com.evolute.utils.sql.Insert;
|
|
|
|
|
import com.evolute.utils.sql.SQLQuery;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
@ -24,15 +35,15 @@ import javax.servlet.http.HttpSession;
|
|
|
|
|
*/
|
|
|
|
|
public class Dblocal
|
|
|
|
|
{
|
|
|
|
|
// String server = "evoserver";
|
|
|
|
|
// String port = "5432";
|
|
|
|
|
// String database = "siprp_local_3_20100813";
|
|
|
|
|
String User = "postgres";
|
|
|
|
|
String Pass = null;
|
|
|
|
|
|
|
|
|
|
String server = "localhost";
|
|
|
|
|
String port = "5436";
|
|
|
|
|
String database = "siprp_local_3";
|
|
|
|
|
String User = "postgres";
|
|
|
|
|
String Pass = null;
|
|
|
|
|
|
|
|
|
|
// String server = "localhost";
|
|
|
|
|
// String port = "5432";
|
|
|
|
|
// String database = "siprp_local";
|
|
|
|
|
|
|
|
|
|
String connectionURL = "jdbc:postgresql://" + server + ":" + port + "/" + database;
|
|
|
|
|
|
|
|
|
|
@ -58,7 +69,7 @@ public class Dblocal
|
|
|
|
|
// application.setLocalConnection(connection);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
new DefaultDatabaseInitializer( server, port, database, User, Pass ).doInit();
|
|
|
|
|
|
|
|
|
|
// Insert.setDefaultKeyRetriever( PostgresqlAutoKeyRetriever.RETRIEVER );
|
|
|
|
|
// ProviderRegistry.registerDefaultProviderFactory( new EvoDataProviderFactory() );
|
|
|
|
|
// ConnectionIdentity conn = new ConnectionIdentity( connectionURL, User );
|
|
|
|
|
@ -68,6 +79,29 @@ public class Dblocal
|
|
|
|
|
//
|
|
|
|
|
// Singleton.setInstance( Singleton.DEFAULT_OBJECT_PROVIDER, provider );
|
|
|
|
|
// Singleton.setInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER, provider );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// new DefaultDatabaseInitializer( server, port, database, User, Pass ).doInit();
|
|
|
|
|
// Singleton.setInstance( Singleton.DATABASE_NAME, database );
|
|
|
|
|
String dbUrl = "jdbc:postgresql://" + server + ":" + port + "/" + database + "?logUnclosedConnections=true&loginTimeout=10&tcpKeepAlive=true";
|
|
|
|
|
|
|
|
|
|
// System.out.println("Using database at [" + dbUrl + "]" );
|
|
|
|
|
|
|
|
|
|
DBManager dbManager = new JDBCManager( dbUrl, User, Pass, 14, 7, 7, new SQLQuery[]{} );
|
|
|
|
|
|
|
|
|
|
Insert.setDefaultKeyRetriever( PostgresqlAutoKeyRetriever.RETRIEVER );
|
|
|
|
|
|
|
|
|
|
ProviderRegistry.registerDefaultProviderFactory( new EvoDataProviderFactory() );
|
|
|
|
|
|
|
|
|
|
ConnectionIdentity conn = new ConnectionIdentity( dbUrl, User );
|
|
|
|
|
conn.setPassword( Pass );
|
|
|
|
|
StatementExecuterFactory.initialize( new DBStatementExecuter( dbManager.getExclusiveExecuter( this ) ) );
|
|
|
|
|
ProviderRegistry.registerDefaultConnection( conn );
|
|
|
|
|
|
|
|
|
|
// Singleton.setInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER, ProviderRegistry.getDefaultProvider( conn ) );
|
|
|
|
|
// Singleton.setInstance( Singleton.DEFAULT_OBJECT_PROVIDER, ProviderRegistry.getDefaultProvider( conn ) );
|
|
|
|
|
// Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, dbManager );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
|
|
|
|
|
|