Error in Database Connection

Hi All,
In JDeveloper, I have created a new Database Connection. While testing the connection,Test Connection is Success.
But next step am clicking Next button, it is throwing the following error. tnsnames.ora and DBC files are correct.
It is showing the following error:
Validation Failed
No database connection available
Listener refused the connection with the following error:
ORA-12504, TNS:listener was not given the SID in CONNECT_DATA
I am able to connect with the database in PL/SQL Developer.
Thanks and Regards,
Myvizhi

Hi,
My tnsnames contains the following entry:
dcap1=
(DESCRIPTION=
(ADDRESS_LIST=
(LOAD_BALANCE=YES)
(FAILOVER=YES)
(ADDRESS=(PROTOCOL=tcp)(HOST=hostname1)(PORT=1533))
(ADDRESS=(PROTOCOL=tcp)(HOST=hostname2)(PORT=1533))
(CONNECT_DATA=
     (SERVICE_NAME=dcap1)
Could you please suggest where am missing.
Thank you very much.
Kind Regards,
Myvizhi

Similar Messages

  • Error during database connection to the database : MS SQL Server 2008 R2

    Hi All,
    I am working with ABAP Proxy to Rec JDBC( Integrating XI with MS SQL Server 2008 R2). I am using SAP PI 7.0
    I am getting error in RWB at communication channel monitoring :
    Error during database connection to the database URL 'jdbc:microsoft:sqlserver://10.1.92.111:1433;database=XONTUSERVENTURA_ORG_TEST' using the JDBC driver 'com.microsoft.jdbc.sqlserver.SQLServerDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:microsoft:sqlserver://10.1.92.111:1433;database=XONTUSERVENTURA_ORG_TEST': SAPClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver'
    I have given Connection details at Rec JDBC Communication channel as :
    JDBC Driver as : com.microsoft.jdbc.sqlserver.SQLServerDriver
    Connection : jdbc:sqlserver://10.1.92.111:1433;database=XONTUSERVENTURA_ORG_TEST.
    Please help me in this regard. I really appreciate your valuable information and time.
    Thanks and Regards,
    Ayub.
    Edited by: Ayubsajjid on Feb 15, 2012 8:49 AM

    Hi All,
    Thanks for all your valuable inputs on my question...
    As per all your inputs, we have to install/Deploy the below required jar files in the aii_af_jmsproviderlib.sda file
    ojdbc14.jar
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Can you please tell me from where we will exact this .jar file, bcoz we have search lotzz but we helpless.
    We install from this link http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=21599--> we download sqljdbc_3.0.1301.101_enu  file >sqljdbc_3.0>enu-->in that I find sqljdbc.jar and sqljdbc4.jar files only . I cant above said .jar files.
    Please help me.
    Regards,
    Ayub.

  • Error during database connection (JDBC)

    Hello!
    When I try testing my connection to MSSQL (using sender JDBC channel) in communication channel monitoring (RWB)i can read that Error explanation:
    Error during database connection to the database URL 'jdbc:microsoftsqlserver://<DB_IP_ADRESS>:1433;databaseName=XXXX' using the JDBC driver 'com.microsoft.jdbc.sqlserver.SQLServerDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Unable to locate a suitable JDBC driver to establish a connection to URL 'jdbc:microsoftsqlserver://<DB_IP_ADRESS>:1433;databaseName=XXXX''
    Before I did the communication channel configuration I did the driver instalation and deploy like in document "HowTo_ConfigExtAdapters". In Adapter Monitor (RWB) i can see the JDBC adapter instaled and started (gray square).
    Any idea what is wrong?

    hi,
    try this:
    jdbc:microsoft:sqlserver://
    and not
    jdbc:microsoftsqlserver
    Regards,
    michal

  • Win7 and now Server Error [2007]: "Database connection information not acce

    I support a 8.3.x server with Insight plugin in use. This has worked for some time now with WinXP. The issue comes into play when the company is upgrading users to Win7 stations. First, the zero-admin (download and install setup launch) is failing. The Install window opens but doesn't seem to be able to complete. Then, when we do get the plugin installed via the manual download and install, we then reach a point where the bqy will not connect with the Server Error [2007]: "Database connection information not accessible. Processing is disabled." If we proceed from there, we'll get Server Error [6] PUB_NullArgument errors and empty "Show Values" limit boxes. So it's like the .oce information is not received on the Win7 platform - it still works fine on WinXP installations.
    And, I know it can work, as the PC Support personnel were able to get this working on one PC.
    Any suggestions?
    Thanks,
    Keith

    I assume that there has been no reply to this thread. The problem still persists, with intermittent success. I hope that someone can shed some light onto the Server Error [2007]: "Database connection information not accessible. Processing is disables." message.
    Thanks again,
    Keith

  • FIM 2010 Sync Error : stopped-database-connection-lost

    Hello everyone,
    a weird thing just happened to me,
    i'm synchronizing my MA and suddently i get the "stopped-database-connection-lost" error
    i have 5 Galsync MAs working perfectly and this sixth one just failing ... (since like today)
    which makes me wonder what is happening ... ?
    any ideas ?
    thanks !
    Hitch Bardawil

    Hitch,
    Look in the event log on the FIM Sync Server and on the SQL Server.
    This error occurs when FIM can't contact the SQL Server that hosts the FIMSynchronizationService database.
    Does this happen every time the sixth MA is run? What if you run them in a different order (might help us distinguish between a resource issue and something specific to that MA)?
    Here are a few related threads:
    http://social.technet.microsoft.com/Forums/en-US/65920fc0-a9ac-4a87-892f-338a6884cbd5/action?threadDisplayName=fim-ma-run-profile-stuck-with-stoppeddatabaseconnectionlost
    http://social.technet.microsoft.com/Forums/en-US/39129eac-09d3-48ff-83f9-ecb4ae2424b6/action?threadDisplayName=sharepoint-profile-synch-stoppeddatabaseconnectionlost
    David Lundell, Get your copy of FIM Best Practices Volume 1 http://blog.ilmbestpractices.com/2010/08/book-is-here-fim-best-practices-volume.html

  • DRM-21003 error for database connection

    Hi,
    I installed DRM 11.1.2 for win32 on my laptop and when I tried to set up database connection (to 11g XE), I am getting error message:
    Connection Failed: DRM-21003: The Oracle.DataAccess client is not the expected version.
    I installed Oracle XE 11.2.0.2 on my laptop. I also tried to connect to 10g server(10.2.0.4), but still has the same error.
    Thanks.
    -Rong

    Hi,
    Apparently,this is a bug in version 11.2.1.0.I had the same issue.I believe this is an bug identified internally.BUG # 9911822.I uninstalled 11.2.1.0 and installed 11.2.1.102 version of the DRM software and this error no longer appears.
    -Sireesha.

  • Error on DataBase connection

    Hi,
    I try to connect my application (developt in C#) to an Oracle DataBase (in version 9.2.0.7.0).
    In order to do that I use the following connection string :
    "Data Source = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST= myadress())"+
                        "(PORT=1528))(CONNECT_DATA=(SERVICE_NAME=servicename())));User Id=myaccount();Password=mypassword();";
    And then :
    using (var conn = new OracleConnection(GetConnectionString()))
         string Query = "SELECT * FROM DATA";
         var cmd = new OracleCommand(Query, conn);
         conn.Open();
    I try to use the client 12.1 by using the Oracle.ManagedDataAccess.dll but I receive  the following error :
    "ORA-03111: Interruption reçue sur le canal de communication"
    Nevertheless, I find in this communities: "The Oracle 12c client can only connect to Oracle DB 10.2 or later. 9.2 requires using Oracle 11.2 client or earlier." Link
    That's why I try with client 11.2 by using Oracle.DataAccess.dll. But I receive another error :
    "ORA-03134: Connections to this server version are no longer supported."
    The DBA seems does not know why it doesn't work. So, can someone help me ?
    Thanks a lot

    If 12c doesn't show up when you click on "Deinstall Products" on the Oracle Universal Installer, then you have the 12c Home uninstalled.
    Try this. Go to your Oracle Home for ODAC 11.2. The directory will be something like the following: C:\app\<user>\product\11.2.0\client_1.
    Run the sqlplus.exe from this directory and try to connect to the 9.2.0.7 DB.
    If it gives you the same error, then my suspicion is that DB 9.2.0.7 is too old of a release. You can either move the DB server to a higher version or try an even older ODP.NET 11.2 version or an 11.1 version.
    I believe 9.2.0.8 was the last patchset available for the 9.2 line.

  • Recieving error 8001: Database connection could not be found

    In hyperion reports 11.1.1.3 I am trying to create a new report. I created a new connection and after i created a new grid I wanted to see what is looks like. when I launched it. I recieved the error 8001: The database could not be found 8c5a0a4_13c44c8A227_-7d10 I tried other connections I recieved the same error. Just to make sure I tested an extising report and it worked fine. Can some one please tell me what I am missing and what do i need to do to get this wo work. Any help is appreciated

    I logged out of Hyperion reports and logged back into the application and I had a connection with no issues

  • ODBC and C# Error + Oracle database connection

    Hi,
    I am Using odbc connection to connect the database
    using System.Data.Odbc;
    OdbcConnection con = new OdbcConnection();
    con.ConnectionString = "Dsn=MYDSN";
    OdbcCommand myCommand = con.CreateCommand();
    in the code i am creating the table and populating the data.
    I am able to create the table,where as i am not able to insert the data
    for (int i = 0; i < 2 ; i++)
    myCommand.CommandText = "Insert into mytable (Col1,......) values (:param1,.......)"
    myCommand.Prepare();
    myCommand.Parameters.AddWithValue("?", 0);
    myCommand.Parameters.AddWithValue("?", 0);
    myCommand.ExecuteNonQuery();
    myCommand.Parameters.Clear();
    Error:
    System.Data.Odbc.OdbcException
    at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
    at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
    at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
    at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
    Where is the Problem.
    Thanks!

    933663 wrote:
    Hi,
    I am Using odbc connection to connect the database
    using System.Data.Odbc;
    OdbcConnection con = new OdbcConnection();
    con.ConnectionString = "Dsn=MYDSN";
    OdbcCommand myCommand = con.CreateCommand();
    in the code i am creating the table and populating the data.
    I am able to create the table,where as i am not able to insert the data
    for (int i = 0; i < 2 ; i++)
    myCommand.CommandText = "Insert into mytable (Col1,......) values (:param1,.......)"
    myCommand.Prepare();
    myCommand.Parameters.AddWithValue("?", 0);
    myCommand.Parameters.AddWithValue("?", 0);
    myCommand.ExecuteNonQuery();
    myCommand.Parameters.Clear();
    Error:
    System.Data.Odbc.OdbcException
    at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
    at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
    at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
    at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
    Where is the Problem.
    Thanks!ERROR?
    What Error?
    I do not see any ORACLE error code & message.
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Error in database connectivity

    sir i want to connect jsp with MS-Access
    the code is--------
    <!-- jai shri ram -->
    <html>
    <head><title>JAI SHRI RAM</title></head>
    <body>
    <%@ page import="java.sql.*" %>
         <%
         String user1 = null;
         String pass1 = null;
         ResultSet rs = null;
         Statement st = null;
         Connection conn = null;
              try
              String url = "jdbc:odbc:lala" ;
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              conn = DriverManager.getConnection(url,"","");
              st = conn.createStatement();
              rs = st.executeQuery("select * from ram1");
              while(rs.next() )
                   System.err.println( rs.getString("name") );
                   System.out.println(rs.getString("password"));
                   user1 = rs.getString("name");
                   pass1 = rs.getString("name");
                   out.println(user1+" "+pass1);
              catch(Exception e)
                   out.println("there is an error");
              out.println("jai shri ram");
         %>
    </body></html>
    but it is giving an error as it is going into catch block.......
    please help me out..it is veru necessary
    thankyou
    gurav

    Hello ram,
    Can you cath the exception and try to print it and see what is the actual exception.
    ie,
    catch{Exception e){
    out.print(e.getMessage());
    Now post this exception.
    Then we will be able to solve it easily. ok
    And it is not good writing codes like this in JSP. Use a bean for this purpose and include it using <jsp:useBean >tag.ok
    Cheers.!!!!!
    kuttus

  • Error establishing database connection.

    I have a working Internet connection, and not had any trouble whatsoever pulling up any other pages.
    I Received this error message when trying to pull up a specific website. I just installed the latest update, but was having difficulties before I did. My phone is jumpy and keypad is very touchy. Sometimes it types up crazy messages (ex: fhshsmdllk) on its own, and downloaded a whole U2 albulm off of iTunes???
    I Don't know what's going on, but I am vwry aggravated with this error message because I really need to see this websit I'm trying to pull up. HELP please!!

    Hi,
    Please can you specify how you create your DSN for Oracle connection in ODBC Data Source Administrator?
    What did you specify for the TNS Service Name?
    What is the content of your TNSNAMES.ORA file?
    Thx
    Mireille

  • Error wtih database connection string

    Hi,
    I am having Oralce 9i AS on windows. Application which we use is forms and reports.
    We have customised the login screen .Which will ask for only
    1. User name
    2. Password
    Upto now it was working fine but from last few days some of my clients whos machines are Linux based they are getting database prompt also on login screen 1. User name
    2.Password
    3.Database
    which should not occure.
    Please do tell me why it is occuring .
    What is the main root cause of this is there anyone who will help me.
    Its very Urgent.Regards,

    For a forms application to log in, it needs 3 bits of info: the username, the password and the database. Obviously your forms application is getting the database name from somewhere - I'm guessing that it is either hard-coded into the application or it is picking it up somehow from the local machine. You will need to open up the login form in form builder to see how it is working. Look for code called by the login button.
    If it is trying to read from a Window registry setting or other configuration file, that would explain your problem.
    Hard to help without more info.
    Patrick.

  • Error while applying a patch "Unable to get the database connection"

    Dear Experts,
    A patch which got successfully applied is failing Production and the error is kind of surprising to me.
    Apps version is 11.5.10.2
    db version is 10.2.0.4
    The worker log file shows
    Time when worker restarted job: Thu Nov 24 2011 22:14:52
    Start time for file is: Thu Nov 24 2011 22:14:52
    adjava -ms128m -mx256m -nojit oracle.apps.fnd.odf2.FndXdfCmp &un_apps &pw_apps &un_apps &pw_apps &jdbc_protocol &jdbc_db_addr table &fullpath_pa_patch/115
    Reading product information from file...
    Reading language and territory information from file...
    Reading language information from applUS.txt ...
      Temporarily resetting CLASSPATH to:
      "/erp/oracle/prodappl/ad/11.5.0/java/adjri.zip:/usr/java14/jre/lib/charsets.jar:/usr/java14/jre/lib/core.jar:/usr/java14/jre/lib/graphics.jar:/usr/java1
      Calling /usr/java14/bin/java ...
    Exception occured
                  Copyright (c) 2003 Oracle Corporation
                     Redwood Shores, California, USA
             XDF(XML Object Description File) Comparison Utility
                            Version 1
    NOTE: You may not use this utility for custom development
          unless you have written permission from Oracle Corporation.
    Unable to get the database connection using schema username/passwordIo exception: The Network Adapter could not establish the connection
    AD Run Java Command is complete.
                         Copyright (c) 2002 Oracle Corporation
                            Redwood Shores, California, USA
                                        AD Java
                                     Version 11.5.0
    NOTE: You may not use this utility for custom development
          unless you have written permission from Oracle Corporation.
    AD Worker error:
    The above program failed.  See the error messages listed
    above, if any, or see the log and output files for the program.
    Time when worker failed: Thu Nov 24 2011 22:14:53
    {code}
    The error says database connection error.  I am able to connect to the database using sqlplus.  I tried to restart the failed worker, but the same error is repeating. 
    Any help would be appreciated.
    Thanks
    qARS
    Edited by: user7640966 on Nov 24, 2011 9:07 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hussein,
    One thing which I noticed now is in the apps Tier the
    tnsnames.ora under $TNS_ADMIN
    shows entry like this:
    PROD=
            (DESCRIPTION=
                    (ADDRESS=(PROTOCOL=tcp)(HOST=<appsServerName>)(PORT=1521))
                    (ADDRESS=(PROTOCOL=tcp)(HOST=<dbServer>)(PORT=1521))
                (CONNECT_DATA=
                    (SID=PROD)
            )Actually *(ADDRESS=(PROTOCOL=tcp)(HOST=<appsIPaddress>)(PORT=1521))* this line in the tnsnames.ora is not correct. In fact the appsServerName should be replaced with dbServerName
    I deleted the tnsnames.ora and reran autoconfig but it is again recreating the same entry.
    Any clue how this can be fixed?
    Thanks
    qARS

  • Creating new Data Source Error - Database connection Failed

    Successfully installed and configured 11.1.1.3.0. Planning and Essbase dev.
    Went to Workspace > Administer > Classing Planning Administration > Manage Data Sources > Create Data Source.
    Entered all info about the application database , etc. Getting error "The database connection failed" (I was able to connect with no problem during the install)
    SQL server 2005 is on the same physical server.
    The diagnostic tool shows database connection passed for planning. A new database was created for the new application.
    The server event viewer shows these errors.
    "Login failed for user 'xxx-hyperion'. The user is not associated with a trusted SQL Server connection."
    Group Policy Error "The client-side extension could not apply computer policy settings for 'Default Domain Policy {xxx}' because it failed with error code '0x80070003 The system cannot find the path specified.' See trace file for more details. "
    The Group Policy client-side extension Group Policy Services failed to execute. Please look for any errors reported earlier by that extension.
    Any help is appreciated.

    Datasource for the application.
    I have created a sql db for this planning application (my datasource). See my first message for more details.
    When you create a new planning application, you need to associate it with a data source. Since this is a new install, I don't have any data sources available yet.
    So, "To create, edit or delete data sources, click Manage Data Source."
    This page lets you validate your connection to the database and essbase server. My essbase server connection validates! The database connection does not validate after I enter all the relevant information.
    SCREEN INFO BELOW
    Fields displayed with an asterisk (*) are mandatory.
    Data Source Name *:
    Data Source Description:
    Select Database Platform
    Microsoft SQL Server
    Application Database
    Server * :
    Port * :
    Database *:
    User *:
    Password *:
    Click "Validate Database Connection"
    ERROR ---> Database connection failed.
    So it does not let me create a data source for my new planning application, so I cannot create a new planning application.
    Thanks in advance.

  • Using database connection in a servlet and get errors after 8 hours

    Hey,
    I'm running a poker script using applet/servlets and it works great. But for some reason about about 8 hours that database layer stops working. At first I thought it was the connections to mySQL that were timing out (because im using connection pooling) but after turning pooling off (I now create the connection each time) I'm still seeing that same error (I can create a connection but when I do an action ex. like a select statment I get an error). What i'm wondering could it be that the driver I load with Class.forName() some how unloads it's self after x amount of time not being used? Not sure if that is it but if anyone could give me some insight that would be great. The Error i recieve is below:
    INFO: Database Event:DatabaseController: Error executing database query.
    ERROR: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: Software caused connection abort: recv failed
    STACKTRACE:
    java.net.SocketException: Software caused connection abort: recv failed
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(Unknown Source)
         at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:104)
         at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:144)
         at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:172)
         at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1839)
         at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2288)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2784)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2370)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
         at com.mysql.jdbc.Statement.executeQuery(Statement.java:1183)
         at com.softnet.database.DatabaseController.executeDatabaseQuery(DatabaseController.java:190)
         at com.softnet.games.GameServer.validateUser(GameServer.java:438)
         at com.softnet.games.GameServer.handleData(GameServer.java:113)
         at com.softnet.network.HttpConnectionThread.run(HttpServletListener.java:191)
    ** END NESTED EXCEPTION **
    I know the query is good because it works all other times just not after about 8 hours.
    --Z3r0CooL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hey,
    Thanks for the responces. For the connection pooling I would open 5 connections and keep them open. So i though maybe after 8 hours after not being used they would timeout. Thats why i turned off conection pooling and create a new connection each time. Anyways i'll post the code below incase i made a mistake somewhere.
    package com.softnet.database;
    /************************ DatabaseControler **************************/
    import java.sql.*;
    import java.util.*;
    import com.softnet.database.DatabaseConnectionPool;
    import com.softnet.database.DatabaseSettings;
    public class DatabaseController
    implements DatabaseListener
         //Used to make sure the database driver is loaded
         private boolean databaseDriverState = false;
         //Used to store a database connection
         private Connection databaseConnection = null;
         //If to user connection pooling or not
         private boolean useConnectionPooling = false;
         //Used to hold the connection pool varible
         private DatabaseConnectionPool connectionPool = null;
         //Used to store database settings
         private DatabaseSettings databaseSettings;
         //Used to hold the DatabaseController listeners
         private List databaseControllerListeners = new ArrayList();
         //min number of connections for connection pool
         private int minNumberOfConnections = 1;
         //max number of connections for connection pool -1 is unlimited
         private int maxNumberOfConnections = -1;
         //DatabaseController Constructors
         public DatabaseController(DatabaseSettings databaseSettings)
              this.databaseSettings = databaseSettings;
              databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
         public DatabaseController(DatabaseSettings databaseSettings, boolean useConnectionPooling, int minNumberOfConnections, int maxNumberOfConnections)
              this.databaseSettings = databaseSettings;
              this.useConnectionPooling = useConnectionPooling;
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
              if(useConnectionPooling == true)
                   connectionPool = new DatabaseConnectionPool(databaseSettings, minNumberOfConnections, maxNumberOfConnections);
                   connectionPool.addDatabaseListener(this);
              else
                   databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
         public DatabaseController() {}
         //Database Settings Get/Set
         public DatabaseSettings getDatabaseSettings()
              return databaseSettings;
         public void setDatabaseSettings(DatabaseSettings databaseSettings)
              this.databaseSettings = databaseSettings;
         //Connection Pooling Get/Set
         public boolean getConnectionPooling()
              return useConnectionPooling;
         public void setConnectionPooling(boolean useConnectionPooling, int minNumberOfConnections, int maxNumberOfConnections)
              this.useConnectionPooling = useConnectionPooling;
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
              if(useConnectionPooling == true)
                   if(connectionPool == null)
                        connectionPool = new DatabaseConnectionPool(databaseSettings, minNumberOfConnections, maxNumberOfConnections);
                        connectionPool.addDatabaseListener(this);
              else
                   if(connectionPool != null)
                        connectionPool.destroyConnections();
                        connectionPool.removeDatabaseListener(this);
                        connectionPool = null;
         //Return if there connected
         public boolean isConnected()
              boolean isConnected;
              if(databaseConnection != null)
                   isConnected = true;
              else
                   isConnected = false;
              return isConnected;
         //Used to connect to database or get a connection for the connection pool
         public void connect()
              if(databaseDriverState == false)
                   databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
              //If we dont have a current connection, make one
              if(databaseConnection == null && databaseDriverState == true)
                   if(useConnectionPooling == false)
                        try
                             databaseConnection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                        catch (SQLException sqle)
                             //Raise event
                             raiseDatabaseEvent("DatabaseController: Error connecting to database. \nERROR: " + sqle.getMessage());
                             databaseConnection = null;
                   else
                        databaseConnection = connectionPool.getConnection();
         //Used to disconnect from the database or give back the connection to the connection pool
         public void disconnect()
              if(databaseConnection != null)
                   if(useConnectionPooling == false)
                        try
                             //Close DB Connection
                             databaseConnection.close();
                        catch(SQLException ignore) {}
                        finally
                             databaseConnection = null;
                   else
                        connectionPool.returnConnection(databaseConnection);
                        databaseConnection = null;
         public ResultSet executeDatabaseQuery(String sSQL)
              ResultSet databaseResult = null;
              if(databaseConnection != null)
                   try
                        Statement databaseStatement = databaseConnection.createStatement();
                        databaseResult = databaseStatement.executeQuery(sSQL);
                   catch(SQLException sqle)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error executing database query.\nSQL: " + sSQL + "\nERROR: " + sqle.getMessage());
              return databaseResult;
         public int executeDatabaseUpdate(String sSQL)
              int rowsAffected = -1;
              if(databaseConnection != null)
                   try
                        Statement databaseStatement = databaseConnection.createStatement();
                        rowsAffected = databaseStatement.executeUpdate(sSQL);
                   catch(SQLException sqle)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error executing database update.\nSQL: " + sSQL + "\nERROR: " + sqle.getMessage());
              return rowsAffected;
         //Used to load the Database Driver
         private boolean loadDatabaseDriver(String databaseDriver)
              boolean driverLoaded;
              if(databaseDriver.equals("") == false)
                   try
                        //Load Database Driver
                        Class.forName(databaseDriver).newInstance();
                        driverLoaded = true;
                   catch (Exception e)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error loading database driver. \nERROR: " + e.getMessage());
                        driverLoaded = false;
              else
                   driverLoaded = false;
              return driverLoaded;
         //Wrap the DatabaseConnectionPool Error to the DatabaseController
         public void databaseEventOccurred(DatabaseEvent de)
              raiseDatabaseEvent(de.getErrorMessage());
         //Event Handling Code
         //Used to add database listeners (Its sync'd so you can change the listeners when firing an event)
    public synchronized void addDatabaseListener(DatabaseListener databaseControllerListener)
    databaseControllerListeners.add(databaseControllerListener);
    //Used to remove a listener from the list (Its sync'd so you can change the listeners when firing an event)
    public synchronized void removeDatabaseListener(DatabaseListener databaseControllerListener)
    databaseControllerListeners.remove(databaseControllerListener);
    //Used to send the raise event to the listeners
    private synchronized void raiseDatabaseEvent(String databaseError)
    DatabaseEvent databaseEvent = new DatabaseEvent(this, databaseError);
    Iterator listeners = databaseControllerListeners.iterator();
    while(listeners.hasNext())
         DatabaseListener listener = (DatabaseListener) listeners.next();
    listener.databaseEventOccurred(databaseEvent);
    /********************* DatabaseConnectionPool **************/
    package com.softnet.database;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import com.softnet.database.*;
    import com.softnet.database.DatabaseSettings;
    public class DatabaseConnectionPool
         //min number of connections
         private int minNumberOfConnections = 1;
         //max number of connections -1 is unlimited
         private int maxNumberOfConnections = -1;
         //Store the connections
         protected Hashtable databaseConnections = null;
         //Database Info
         protected DatabaseSettings databaseSettings;
         //to hold Driver state
         private boolean databaseDriverState = false;
         //To hold connection checker
         private DatabaseConnectionCheck connectionChecker = null;
         //Used to hold the DatabaseConnectionPool listeners
         private List databaseConnectionPoolListeners = new ArrayList();
         public DatabaseConnectionPool(DatabaseSettings databaseSettings, int minNumberOfConnections, int maxNumberOfConnections)
              this.databaseSettings = databaseSettings;
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
              //Load Driver
              databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
              //Create connection
              createConnections();
         public DatabaseConnectionPool(int minNumberOfConnections, int maxNumberOfConnections)
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
         //Database Settings Get/Set
         public DatabaseSettings getDatabaseSettings()
              return databaseSettings;
         public void setDatabaseSettings(DatabaseSettings databaseSettings)
              this.databaseSettings = databaseSettings;
         //Driver State Get
         public boolean getDatabaseDriverState()
              return databaseDriverState;
         public void createConnections()
              if(databaseDriverState == false)
                   databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
              //Create all connections and load the minimum in the Hashtable
              if(databaseConnections == null)
                   if(databaseDriverState == true && minNumberOfConnections != 0)
                        databaseConnections = new Hashtable();
                        for(int i = 0; i < minNumberOfConnections; i++)
                             try
                                  databaseConnections.put(DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword()), Boolean.FALSE);
                             catch(SQLException sqle)
                                  //Problem break loop and destroy any connections
                                  destroyConnections();
                                  //Raise event
                                  raiseDatabaseEvent("DatabaseConnectionPool: Error creating database connections. \nERROR: " + sqle.getMessage());
                                  break;
              //If no connection check exists create one
              if(connectionChecker == null)
                   connectionChecker = new DatabaseConnectionCheck(this);
                   connectionChecker.start();
         public Connection getConnection()
              Connection connection = null;
              boolean errorWithConnection = false;
              Enumeration connections = databaseConnections.keys();
              synchronized (databaseConnections)
                   while(connections.hasMoreElements())
                        errorWithConnection = false;
                        connection = (Connection) connections.nextElement();
                        Boolean state = (Boolean) databaseConnections.get(connection);
                        //If connection is not used, use it.
                        if(state == Boolean.FALSE)
                             try
                                  connection.setAutoCommit(true);
                             catch(SQLException e)
                                  //Problem with connection remove connection and replace it
                                  databaseConnections.remove(connection);
                                  try
                                       connection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                                  catch(SQLException sqle)
                                       errorWithConnection = true;
                             if(errorWithConnection == false)
                                  // Update the Hashtable to show this one's taken
                                  databaseConnections.put(connection, Boolean.TRUE);
                                  // Return the connection
                                  return connection;
                   //All connections being used check to max to see if we can make a new one
                   if(maxNumberOfConnections == -1 || maxNumberOfConnections > databaseConnections.size())
                        try
                             connection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                        catch(SQLException sqle)
                             errorWithConnection = true;
                        if(errorWithConnection == false)
                             databaseConnections.put(connection, Boolean.TRUE);
                             return connection;
              //If not connections free and max connections reached wait for a free connection
              return getConnection();
         public void returnConnection(Connection connection)
              boolean errorWithConnection = false;
              //Make sure connection still works
              try
                   connection.setAutoCommit(true);
              catch(SQLException e)
                   //Problem with connection remove connection and replace it
                   databaseConnections.remove(connection);
                   try
                        connection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                   catch(SQLException sqle)
                        errorWithConnection = true;     
              if(errorWithConnection == false)
                   databaseConnections.put(connection, Boolean.FALSE);
         public void destroyConnections()
              Connection connection = null;
              if(databaseConnections != null)
                   //Close all connections
                   Enumeration connections = databaseConnections.keys();
                   while (connections.hasMoreElements())
                        connection = (Connection) connections.nextElement();
                        try
                             connection.close();
                        catch(SQLException ignore) {}
                   //Free up hashtable
                   databaseConnections = null;
         private boolean loadDatabaseDriver(String databaseDriver)
              boolean driverLoaded;
              if(databaseDriver.equals("") == false)
                   try
                        //Load Database Driver
                        Class.forName(databaseDriver);
                        driverLoaded = true;
                   catch (ClassNotFoundException cnfe)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error loading database driver. \nERROR: " + cnfe.getMessage());
                        driverLoaded = false;
              else
                   driverLoaded = false;
              return driverLoaded;
         //Event Handling Code
         //Used to add database listeners (Its sync'd so you can change the listeners when firing an event)
    public synchronized void addDatabaseListener(DatabaseListener databaseConnectionPoolListener)
    databaseConnectionPoolListeners.add(databaseConnectionPoolListener);
    //Used to remove a listener from the list (Its sync'd so you can change the listeners when firing an event)
    public synchronized void removeDatabaseListener(DatabaseListener databaseConnectionPoolListener)
    databaseConnectionPoolListeners.remove(databaseConnectionPoolListener);
    //Used to send the raise event to the listeners
    private synchronized void raiseDatabaseEvent(String databaseError)
    DatabaseEvent databaseEvent = new DatabaseEvent(this, databaseError);
    Iterator listeners = databaseConnectionPoolListeners.iterator();
    while(listeners.hasNext())
         DatabaseListener listener = (DatabaseListener) listeners.next();
    listener.databaseEventOccurred(databaseEvent);
    class DatabaseConnectionCheck extends Thread
         private DatabaseConnectionPool connectionPool;
         DatabaseConnectionCheck(DatabaseConnectionPool connectionPool)
              this.connectionPool = connectionPool;
         public void run()
              try
                   while(true)
                        //check threads every 30 seconds
                        this.sleep(300000);
                        if(connectionPool.databaseConnections != null)
                             Connection connection = null;
                             Enumeration connections = connectionPool.databaseConnections.keys();
                             synchronized (connectionPool.databaseConnections)
                                  while(connections.hasMoreElements())
                                       connection = (Connection) connections.nextElement();
                                       Boolean state = (Boolean) connectionPool.databaseConnections.get(connection);
                                       //If connection is not used, use it.
                                       if(state == Boolean.FALSE)
                                            try
                                                 connection.setAutoCommit(true);
                                            catch(SQLException e)
                                                 //Problem with connection remove connection and replace it
                                                 connectionPool.databaseConnections.remove(connection);
                                                 try
                                                      connection = DriverManager.getConnection(connectionPool.databaseSettings.getDatabaseURL(), connectionPool.databaseSettings.getUserName(), connectionPool.databaseSettings.getUserPassword());
                                                 catch(SQLException sqle)
                                                      connection = null;
                                                 // Update the Hashtable with new connection if its not null
                                                 if(connection != null)
                                                      connectionPool.databaseConnections.put(connection, Boolean.FALSE);
              catch(InterruptedException ignored) {}     
    Basicly the why it works is the connection pool hold the database connections. When the user needs a connection they use the database controller to request a connection (By create a instance and called the connect() method) and the connection is either created or grabed from the connection pool. After the user is done with the connection they call the disconnect() method which closes the connection or returns it to the connection pool.
    --Z3r0CooL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

Maybe you are looking for

  • Worst customer support and website in the world!

    I have had bad service from businesses here and there, but Verizon home phone service (which I am forced to use in this location) has amazingly bad customer support and a website from hell! Any tips or tricks how to get any human at Verizon to respon

  • How do I make my iPhone stop automatically syncing duplicated Outlook contacts?

    My Outlook stores multiple contacts for the same person automatically (one with an email address only, one with a phone number only, etc.). When my iPhone syncs with the cloud it stores those multiple contacts and makes it frustrating to look up one

  • Is it possible to upgrade the HD?

    Is there a way to upgrade the 1.8inch/80gb HD with a larger HD? I saw on the internet that Toshiba has a 160GB 1.8 inch HD..... Don't even know if it will fit the MBA.... Thanks F

  • DMEE WITH PASSAGE UNICODE

    Hi everybody I need to new how to resolve a problem with the passage to new release (6.0) and unicode. I tried to create a file of payment with DMEE but the file is with format incorrect. There are many "#". thank for your help.

  • Performance: T3 vs. Local Interfaces ?

    Hi there! What gain in performance can be expected from Local Interfaces? T3 and Local Interfaces are ment to tackle the same problem, if I'm not mistaken: enabling a local call to a Bean without serializing the parameters (enabling call by reference