Database Connection Hangs - getConnection()

Dear Friends,
i have a serious problem with a database connectivity,
now the issue is,i have written the code to connect to the databaseserver which is in some remote place,it loads the driver,that's the oracle driver,but when it comes to DriverManager.getConnection,that's the connectivity with the database it hangs.Now first i thought their might be a network problem but then it should give a networkexception,and also i put some dummy userid,password and also the IPAddresse,port number ,and it gave me a SQLException,so i assume that their is no network problem.then my question is why does it get hangs when the control comes to the getConnection method,
what might be the problem?
Is there any problem with the database server? Plz Help Me!

Jeba,
Fill in the blank: Assumption is the mother of all .... ups. :P
I'm not an Oracle expert or even Oracle novice, but some simple principles should apply.
First up, can you reach the database server with simple stuff like ping.
If you can, can you then see shared folders etc from your browser?
If the answer to these is yes, you should not have a network problem.
As a suggestion, try to ensure that you have a user name / password combination with the highest access rights possible - On at least one other database there are issues to do with rights associated with different usernames.
Finally, do you have something like dbVisualiser?
Google it and download it. You already have the jdbc drivers which it needs, so just configure it as needed and see if it can connect. If it can, you may have a problem with your connection string.

Similar Messages

  • Database Connection Hanging!

    Hi,
    We are using oracle 10g(10.1.0.3) on solaris 5.9.We are facing a new problem since couple of weeks.The problem is ,when try to connect to database , it is hanging and unable to connect.
    When I check ps -ef | grep gdwd (where gdwd is the listener name), this is result.
    glgldvdb01[export/home/oracle]ps -ef | grep gdwd
    oracle 11400 1 0 Apr 05 ? 67:08 /u00/oracle/product/gdwd/db_1/bin/tnslsnr gdwd -inherit
    oracle 15638 15633 0 09:00:29 ? 0:00 /u00/oracle/product/gdwd/db_1/bin/tnsping (ADDRESS=(PROTOCOL=TCP)(HOST=glgldvdb
    oracle 29007 29003 0 19:34:29 ? 0:00 /u00/oracle/product/gdwd/db_1/bin/lsnrctl
    oracle 10073 1 0 19:40:29 ? 0:00 sh -c /u00/oracle/product/gdwd/db_1/bin/tnsping "(ADDRESS=(PROTOCOL=TCP)(HOST=g
    oracle 10077 10073 0 19:40:29 ? 0:00 /u00/oracle/product/gdwd/db_1/bin/tnsping (ADDRESS=(PROTOCOL=TCP)(HOST=glgldvdb
    oracle 12273 12270 0 19:25:29 ? 0:00 /u00/oracle/product/gdwd/db_1/bin/tnsping (ADDRESS=(PROTOCOL=TCP)(HOST=glgldvdb
    oracle 12270 1 0 19:25:29 ? 0:00 sh -c /u00/oracle/product/gdwd/db_1/bin/tnsping "(ADDRESS=(PROTOCOL=TCP)(HOST=g
    oracle 18352 16849 0 09:01:40 pts/4 0:00 grep gdwd
    oracle 11319 11400 0 19:24:36 ? 0:00 /u00/oracle/product/gdwd/db_1/bin/tnslsnr gdwd -inherit
    oracle 15633 15590 0 09:00:29 ? 0:00 sh -c /u00/oracle/product/gdwd/db_1/bin/tnsping "(ADDRESS=(PROTOCOL=TCP)(HOST=g
    oracle 29003 1 0 19:34:29 ? 0:00 sh -c /u00/oracle/product/gdwd/db_1/bin/lsnrctl > /tmp/DJwjCbRvFF
    If I killed all the processes and start the listener (gdwd) again, then no issue.But this problem is coming almost frequently.Could anyone can explain about this with solution?
    Note : We are in two node RAC environment.
    Thanks in advance,
    Rajesh Marath
    Message was edited by:
    Rajesh Marath

    Pls check listener.log, is there any error. ?
    Also search metalink/open tar, this might be a known issue.
    Cheer,
    Virag Sharma
    Message was edited by:
    virag_sh

  • Database connection Hangs - Urgent

    Hello
    I installed 9i db on one machine and I was able to connect from clients, then I installed 9ias on the same machine and now sqlplus hangs on the client when i try to connect. however tnsping is going thru.
    Please , where/what do i need to do?. Such a configuration already exists on another machine and works fine (development).
    Please help. my client getting impatient

    Hi Thanks for the response.
    Below are the listener configs for both infra and db, and also the status of the db listener.
    NB. My application is able to connect via the middle tier(application server) !
    Listener Status at DB Home:
    LSNRCTL> status
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for 32-bit Windows: Version 9.2.0.4.0 - Produc
    tion
    Start Date 11-MAR-2004 12:26:41
    Uptime 3 days 20 hr. 20 min. 6 sec
    Trace Level off
    Security OFF
    SNMP OFF
    Listener Parameter File C:\oracle\ora92\network\admin\listener.ora
    Listener Log File C:\oracle\ora92\network\log\listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pProd)(PORT=1521)))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "pProdhru.pProd.com" has 1 instance(s).
    Instance "pProdhru", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully
    Listener Config at DB Home:
    # LISTENER.ORA Network Configuration File: C:\oracle\ora92\network\admin\listener.ora
    # Generated by Oracle configuration tools.
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = pProd)(PORT = 1521))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\ora92)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = pProdhru.pProd.com)
    (ORACLE_HOME = C:\oracle\ora92)
    (SID_NAME = pProdhru)
    Listener at Infrastructure Home:
    # LISTENER.ORA Network Configuration File: c:\ProdINFRA\network\admin\listener.ora
    # Generated by Oracle configuration tools.
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = pProd)(PORT = 1521))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = c:\ProdINFRA)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = iasdb.pProdhru.pProd.com)
    (ORACLE_HOME = c:\ProdINFRA)
    (SID_NAME = iasdb)
    Any Thing I'm Missing ?

  • JDBC Connection Hangs

    I'm using the connection pooling system from Jakarta commons. My database access works fine most of the time, but for some reason sometimes the database hangs. I will try to access the web-app and the login screen will come up fine, but when I try to log in the app will just sit there trying to access the database forever, and from that point on no database access will work. Here is the code I use to get the connections and access the database. Is there anything I am doing wrong that could be causing this?
    import java.sql.DriverManager;
    import java.sql.Connection;
    import javax.sql.DataSource;
    import java.io.PrintWriter;
    import org.apache.commons.pool.ObjectPool;
    import org.apache.commons.pool.impl.GenericObjectPool;
    import org.apache.commons.dbcp.ConnectionFactory;
    import org.apache.commons.dbcp.PoolingDataSource;
    import org.apache.commons.dbcp.PoolableConnectionFactory;
    import org.apache.commons.dbcp.DriverManagerConnectionFactory;
    public class ConnectionManager {
         private static final ConnectionManager INSTANCE = new ConnectionManager();
         //Name of SQL Driver to load
         private static final String DRIVERNAME = "com.mysql.jdbc.Driver";
         private static final String CONNECTSTRING = "jdbc:mysql:///mysite:admin:mypasswd?autoReconnect=true";
         //The actual pool of Database Connections
         private static DataSource dataSource;
         private static ObjectPool connectionPool;
         // Private constructor supresses
         // default public constructor
         private ConnectionManager( ) {
              // Load the Database SQL Driver
              try{
                   Class.forName(DRIVERNAME);
              } catch (java.lang.ClassNotFoundException e) {System.out.println ("Database SQL Driver not found!");}
              try {
                   // First, we'll need a ObjectPool that serves as the
                   // actual pool of connections.
                   // We'll use a GenericObjectPool instance, although
                   // any ObjectPool implementation will suffice.
                   connectionPool = new GenericObjectPool(null);
                   // Next, we'll create a ConnectionFactory that the
                   // pool will use to create Connections.
                   // We'll use the DriverManagerConnectionFactory,
                   // using the connect string passed in the command line
                   // arguments.
                   ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(CONNECTSTRING,null);
                   // Now we'll create the PoolableConnectionFactory, which wraps
                   // the "real" Connections created by the ConnectionFactory with
                   // the classes that implement the pooling functionality.
                   PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);
                   // Finally, we create the PoolingDriver itself,
                   // passing in the object pool we created.
                   // We then save the datasource object to the class for later use in getting connections
                   dataSource = new PoolingDataSource(connectionPool);
                   //System.out.println("Idle: " + connectionPool.getNumIdle() + " - Active: " + connectionPool.getNumActive());
                   } catch (Exception e){}
         //Returns and Instance of the ConnectionManager object (not really necessary)
         public static ConnectionManager getInstance( ) {
              return INSTANCE;
         //Returns a database connection object
         public static Connection getConnection(){
              Connection conn = null;
              try{
                   conn = dataSource.getConnection();
                   } catch(java.sql.SQLException e){
                       System.err.print (e.getStackTrace());
              //System.out.println("Idle: " + connectionPool.getNumIdle() + " - Active: " + connectionPool.getNumActive());
              return conn;
    And here is my database code:
    import java.sql.*;
    import com.mysite.ConnectionManager;
    import java.util.HashMap;
    import java.util.Iterator;
    Manages a database after getting a database connection from a {@url ConnectionManager} object.
    Can do queries and database updates, as well open and close connections.
    public class DatabaseManager {
         private Connection con = null;
         private Statement st;
         private ResultSet rs;
         //The Structure of the Table, used for query operations
         private String[] tableStruct;
         Constructor
         public DatabaseManager(){
         Retrieves a database connection from a {@url ConnectionManager} object.
         @param
         @return
         @see
         public void connect(){
              con = ConnectionManager.getConnection();
         Identifies whether this database connection is still open
         @param
         @return
         @see
         public boolean isClosed() throws java.sql.SQLException{
              return con.isClosed();
         Execute a query on a database connection and get the resultset for that query
         @param queryString A String representing the database query
         @return The results of the query to the database
         @see Statement, ResultSet
         public ResultSet query(String queryString) throws java.sql.SQLException{
              if (con != null){
                   st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                   st.executeQuery (queryString);
                   rs = st.getResultSet();
                   return rs;
              else {
                   throw new java.sql.SQLException ("Error has occurred in Datamanager, no Database Connection has been Established.");
         Returns the Number of Rows the last query has executed.
         @return Number of Rows
         public int getRows() throws java.sql.SQLException{
              int count = 0;
              if (rs != null){
                   //get the current row number in case were in the middle of a read and want the size
                   int rowNumber = rs.getRow();
                   rs.beforeFirst();
                   while (rs.next()){
                        count = count + 1;
                   if (rowNumber == 0){
                        rs.beforeFirst();     
                   else {
                        rs.absolute(rowNumber);     
                   return count;
              else {
                   return 0;
         Does a record in a particular table exist.
         @param tableName name of Table to look in
         @param idName Name if Table ID
         @param id value of ID
         @return True if record exists
         @see
         public boolean doesExist(String tableName, String idName, String id) throws java.sql.SQLException{
              query ("SELECT " + idName + " FROM " + tableName + " WHERE " + idName + "='" + id + "';");
              if (getRows() == 1){
                   return true;
              else {
                   return false;
         Update a line (or multiple lines) in the database.
         @param updateString The Update Query String to use to update the database
         @return
         public int update(String updateString) throws SQLException{
              int j = 0;
              try {
                   st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                   j = st.executeUpdate (updateString);     
              catch (SQLException e) {
                   throw new SQLException (updateString);
              st.close();
              return j;
         Update a line in the database.
         @param  tableName Name of table to update the line
         @param  items The data to be updated in the table
         @return
         public int update(String tableName, HashMap items, String idname) throws SQLException{
              // UPDATE <tablename> SET name1="value1", name2="value2" WHERE id="idvalue"
              String updateString;
              Iterator keys = items.keySet().iterator();
              Iterator values = items.values().iterator();
              String optionsString = "";
              //Combine the keys into Strings with ,'s separating.
              while (keys.hasNext()){
                   optionsString = optionsString + (String)keys.next() + "=\"" + (String)values.next() + "\",";
              //Chop off the last , in the Strings
              optionsString = optionsString.substring (0, optionsString.length()-1);
              updateString = "UPDATE " + tableName + " SET " + optionsString + " WHERE " + idname + "=" + items.get(idname) + ";";
              return insert (updateString);
         Delete a Record or Records from the database
         @param table Name of the Table to delete data from
         @param whereClause what to delete from the table
         @see
         public void delete(String table, String whereClause) throws SQLException{
              String deleteString;
              deleteString = "DELETE FROM " + table;
              if (whereClause != null) {
                   if (!whereClause.equals("")){
                        deleteString += (" WHERE " + whereClause);
              deleteString += ";";
              st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
              st.execute (deleteString);
              st.close();
         Inserts a line of data into a database connection under a given table
         @param insertString String Containing the query to send with the Insert Data
         @return Number of Rows Affected
         public int insert(String insertString) throws SQLException{
              int j = 0;
              try {
                   st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                   j = st.executeUpdate (insertString);     
              catch (SQLException e){
                   throw new SQLException (insertString);
              st.close();
              return j;
         Inserts a line of data into a database connection under a given table
         @param  tableName Name of table to update the line
         @param  items The data to be updated in the table
         @return Number of Rows Affected
         public int insert(String tableName, HashMap items) throws SQLException{
              // REPLACE INTO <tablename> (itemname1, itemname2) VALUES ("value1", "value2");
              String insertString;
              Iterator keys = items.keySet().iterator();
              Iterator values = items.values().iterator();
              String keysString = "";
              String valuesString = "";
              //Combine the keys into Strings with ,'s separating.
              while (keys.hasNext()){
                   keysString = keysString + (String)keys.next() + ",";
                   valuesString = valuesString + "\"" + (String)values.next() + "\",";
              //Chop off the last , in the Strings
              keysString = keysString.substring (0, keysString.length()-1);
              valuesString = valuesString.substring (0, valuesString.length()-1);
              insertString = "REPLACE INTO " + tableName + " (" + keysString + ") VALUES (" + valuesString + ");";
              return insert (insertString);
         Sets the table structure for subsequent operations.
         @param An array of names that represent a table in a database.
         @return
         @see
         public void setStructure(String[] struc){
              tableStruct = struc;
         Flushes the Statement and ResultSet object
         in case any resources are being used when they
         shouldn't be.
         public void flushSources() throws java.sql.SQLException{
              if (rs != null){
                   rs.close();
                   rs = null;
              if (st != null){
                   st.close();
                   st = null;
         Kills the database connection in this object
         public void close() throws java.sql.SQLException{
              flushSources();
              if (con != null){
                   con.close();     
              con = null;     
         }

    How do I do that, it doesn't even report an error. I could try sticking log traces all over the place, but it may not tell me anything about why the problem is happening.

  • Help! My database connection from BMP Entity bean dies after a while!!!

    Hi all!
    I posted a related post about this lately How do I use connection pooling from BMP Entity Beans in OC4J 10.1.2? but it didn't solve my problems.
    I have some entity beans coded with BMP, so I handle all database stuff myself. I have set up datasources.xml like this:
        <data-source
            class="com.evermind.sql.DriverManagerDataSource"
            name="OracleDS"
            location="jdbc/OracleCoreDS"
            xa-location="jdbc/xa/OracleXADS"
            ejb-location="jdbc/OracleDS"
            connection-driver="oracle.jdbc.driver.OracleDriver"
            username="scott"
            password="tiger"
            url="jdbc:oracle:thin:@//URL TO DB:SID"
            inactivity-timeout="30"
            min-connections="10"
            max-connections="50"
        />All JNDI connection lookup is done through the ejb-location as I should. I have been through all my try {} catch {} finally {} blocks, so ensure that I close all objects after use.
    After a few hours of inactivity, my program dies. I have inserted a lot of debug statements (System.out.println()), and it seems like the program hangs when it's trying to execute a PreparedStatement.
    I.e. it dies when I do ps.ExecuteQuery in the code below (NOTE: to make things easier to read, I have stripped out all error handling here):
        Context ic = new InitialContext();
        DataSource ds = (DataSource)ic.lookup("jdbc/OracleDS");
        c = ds.getConnection();
        System.out.println("DEBUG: Got database connection.");
        PreparedStatement ps = c.prepareStatement("SELECT foobar FROM footable WHERE foo=?");
        System.out.println("DEBUG: Prepared SQL statement.");
        ps.setString(1,"foo");
        ResultSet rs = ps.executeQuery();
        // Close all objects (rs, ps, c) here.My database is on another physical server, so I wonder if this is caused by an unstable network, or?
    Please help!
    ~Morten

    Hi again!
    Sorry for the delay, but I have been busy lately.
    Anyway: Our application server is 10.1.2, so I don't think patch 4307303 is relevant here. Database server is Oracle 9.2.0.6. Everything runs on Linux (of course) ;-).
    Here's a thread dump:
    Full thread dump Java HotSpot(TM) Server VM (1.4.2_04-b05 mixed mode):
    "ApplicationServerThread-8" prio=1 tid=0x089a9448 nid=0x5902 in Object.wait() [885e6000..885e687c]
         at java.lang.Object.wait(Native Method)
         at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:353)
         - locked <0x91a31e60> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:767)
         at com.evermind.util.ReleasableResourcePooledExecutor.myGetTask(ReleasableResourcePooledExecutor.java:151)
         at com.evermind.util.ReleasableResourcePooledExecutor.access$000(ReleasableResourcePooledExecutor.java:33)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:190)
         at java.lang.Thread.run(Thread.java:534)
    "AJPRequestHandler-ApplicationServerThread-7" prio=1 tid=0x08d78a58 nid=0x5902 runnable [8b2f4000..8b2f587c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at oracle.net.ns.Packet.receive(Unknown Source)
         at oracle.net.ns.DataPacket.receive(Unknown Source)
         at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:978)
         at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:950)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:434)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:661)
         at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:959)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:693)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1065)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2901)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2942)
         - locked <0x914cad08> (a oracle.jdbc.driver.T4CPreparedStatement)
         - locked <0x920256c0> (a oracle.jdbc.driver.T4CConnection)
         at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:270)
         at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:270)
         at com.evermind.sql.PreparedStatementBCELProxy.executeQuery(PreparedStatementBCELProxy.java:31)
         at com.brunata.servicerapport.ejb.CustomerBean.ejbCreate(Unknown Source)
         at CustomerLocalHome_EntityHomeWrapper2.create(CustomerLocalHome_EntityHomeWrapper2.java:420)
         at com.brunata.servicerapport.BeanFactory.getCustomerBean(Unknown Source)
         at com.brunata.servicerapport.CustomerOpenAction.execute(Unknown Source)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at com.brunata.servicerapport.CustomerAuthorizationFilter.doFilter(Unknown Source)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-23" daemon prio=1 tid=0x092ebb18 nid=0x5902 in Object.wait() [88565000..8856587c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x920000f0> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x920000f0> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "Thread-22" daemon prio=1 tid=0x092eb988 nid=0x5902 in Object.wait() [8dfa0000..8dfa087c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92000188> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x92000188> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "AJPRequestHandler-ApplicationServerThread-6" prio=1 tid=0x08c03240 nid=0x5902 runnable [8b0f1000..8b0f187c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at com.evermind.io.SingleReadBufferInputStream.readChunk(SingleReadBufferInputStream.java:116)
         at com.evermind.io.SingleReadBufferInputStream.read(SingleReadBufferInputStream.java:35)
         at com.evermind.server.http.AJPRequestHandler.readAJPPackets(AJPRequestHandler.java:462)
         at com.evermind.server.http.AJPRequestHandler.initRequest(AJPRequestHandler.java:396)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:185)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    "DestroyJavaVM" prio=1 tid=0x08053278 nid=0x5902 waiting on condition [0..bfffcac4]
    "OC4JMonitorThread" daemon prio=1 tid=0x08d7a5a0 nid=0x5902 in Object.wait() [88667000..8866787c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aed1f8> (a java.lang.Object)
         at oracle.ons.NotificationQueue.internalDequeue(NotificationQueue.java:253)
         - locked <0x92aed1f8> (a java.lang.Object)
         at oracle.ons.NotificationQueue.dequeue(NotificationQueue.java:226)
         at oracle.ons.Subscriber.receive(Subscriber.java:136)
         at com.evermind.server.OC4JMonitorThread.run(OC4JMonitorThread.java:315)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-6" daemon prio=1 tid=0x087f9f98 nid=0x5902 in Object.wait() [886e8000..886e887c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aed368> (a java.lang.Object)
         at java.lang.Object.wait(Object.java:429)
         at oracle.ons.NotificationQueue.internalDequeue(NotificationQueue.java:255)
         - locked <0x92aed368> (a java.lang.Object)
         at oracle.ons.NotificationQueue.dequeue(NotificationQueue.java:215)
         at oracle.ons.SenderThread.run(SenderThread.java:81)
    "Thread-5" daemon prio=1 tid=0x087f9d10 nid=0x5902 runnable [88769000..8876987c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at oracle.ons.InputBuffer.readMoreData(InputBuffer.java:267)
         at oracle.ons.InputBuffer.getNextString(InputBuffer.java:222)
         at oracle.ons.ReceiverThread.run(ReceiverThread.java:228)
    "TaskManager" prio=1 tid=0x087f9b30 nid=0x5902 waiting on condition [887ea000..887ea87c]
         at java.lang.Thread.sleep(Native Method)
         at com.evermind.util.TaskManager.run(TaskManager.java:247)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-4" prio=1 tid=0x08ca2fb8 nid=0x5902 in Object.wait() [891e2000..891e287c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aee258> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x92aee258> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "AJPConnectionListener [0.0.0.0/0.0.0.0:3302]" prio=1 tid=0x086f1668 nid=0x5902 runnable [8a7ca000..8a7ca87c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x927a0390> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.http.AJPConnectionListener.run(AJPConnectionListener.java:60)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "RMIServer [0.0.0.0:3202] count:2" prio=1 tid=0x086cbff0 nid=0x5902 runnable [8b172000..8b17287c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x927a0850> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.rmi.RMIServer.run(RMIServer.java:464)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "JMSServer[webprod:3702]" prio=1 tid=0x0879aff0 nid=0x5902 runnable [8b1f3000..8b1f387c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x92746aa0> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.jms.JMSServer.run(JMSServer.java:516)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "LogFlusher" daemon prio=1 tid=0x081b91a0 nid=0x5902 waiting on condition [8b274000..8b27487c]
         at java.lang.Thread.sleep(Native Method)
         at oracle.core.ojdl.BufferedLogWriter$Flusher.run(BufferedLogWriter.java:354)
    "Signal Dispatcher" daemon prio=1 tid=0x080ba9e0 nid=0x5902 waiting on condition [0..0]
    "Finalizer" daemon prio=1 tid=0x080b61a8 nid=0x5902 in Object.wait() [8e9a7000..8e9a787c]
         at java.lang.Object.wait(Native Method)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
         - locked <0x925b0378> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
         at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=1 tid=0x080b5dc8 nid=0x5902 in Object.wait() [8ea28000..8ea2887c]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:429)
         at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
         - locked <0x925b02a0> (a java.lang.ref.Reference$Lock)
    "VM Thread" prio=1 tid=0x080b52e0 nid=0x5902 runnable
    "VM Periodic Task Thread" prio=1 tid=0x080bee08 nid=0x5902 waiting on condition
    "Suspend Checker Thread" prio=1 tid=0x080b9fc8 nid=0x5902 runnable As far as I can see, my PreparedStatement (or connection) is locked.... Any ideas?
    ~Morten ;-)

  • Jdbc connection hang?

    I used thin JDBC driver 9.0.1 comes with oracle 9i.
    However, the connection hang in heavy load.
    1. I try to check isClosed(), then reopen is more stable but problem is still exist.
    2. It's more stable than 1. when do.. getConnection, do job and Close it. But another application connect more difficult get some error like 'not found oracle realm' or something.
    Anybody has comment?
    Thanks,
    Kittikun Potivanakul
    [email protected]

    Hi to all and sorry for the delay of my reply.
    I am not using RAC. After setting of the system property +"-Djava.security.egd=file:///dev/random"+ it has solved the +"Connection reset"+ problem, but after about one hour I get +"Connection closed"+ from each connection of the pool when the application uses it.
    The pool uses the implicit cache mechanism of Oracle. Follow the properties of cache:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
    <properties>
    <comment> Oracle connection pool configuration file. </comment>
    <!-- Sets how many connections are created in the cache when it is created or reinitialized -->
    <entry key="InitialLimit">0</entry>
    <!-- Sets the minimum number of connections the cache maintains. -->
    <entry key="MinLimit">0</entry>
    <!-- Sets the maximum number of connection instances the cache can hold. If missing no limit-->
    <entry key="MaxLimit">10</entry>
    <!-- Sets the maximum time a physical connection can remain idle in a connection cache.
    An idle connection is one that is not active and does not have a logical handle associated with it. -->
    <entry key="InactivityTimeout">240</entry>
    <!-- Sets the maximum time that a connection can remain unused before the connection is closed and returned to the cache.
         A connection is considered unused if it has not had SQL database activity. -->
    <entry key="AbandonedConnectionTimeout">240</entry>
    <!-- If no connection is returned to the cache before the timeout elapses, then the connection request returns null. -->
    <entry key="ConnectionWaitTimeout">5</entry>
    <!-- If true causes the connection cache to test every connection it retrieves against the underlying database. If a valid connection cannot be retrieved, then an exception is thrown. -->
    <entry key="ValidateConnection">true</entry>
    </properties>
    Edited by: user12098943 on Aug 24, 2011 10:31 AM

  • Problem with database connection in Jdev 11

    Hello,
    my jdev version is 11 and i want do really simple task create new database connection to my oracle db.
    I open database navigator and click new connection. i want jdbc connection but after i fill this form i pressed test connection button and get this error msg:
    Test failed: 4
    i think i have correct information but i tried this, i opened my older jdev 10 and copy jdbc url from my old db connection.
    In jdev 11 i checked Enter Custom JDBS Url and pasted url from jdev 10 and i get:
    Test failed: 4
    What is wrong?
    Thanks for your advice.
    J.

    I add new information:
    i cant connect to oracle db 8, but i try another db in my company which is 10 and its working fine.
    I write java class and try connect to db 8 via jdbc manually:
    String url = "jdbc:oracle:thin:@SERVER:1525:SID";
    String user = "user1";
    String password = "aaa";
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection(url, user, password);
    and i get this:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
         at oracle.jdbc.driver.T4C8TTIdty.marshal(T4C8TTIdty.java:468)
         at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:339)
         at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:621)
         at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
         at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:501)
         at java.sql.DriverManager.getConnection(DriverManager.java:525)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
         at project1.Class1.main(Class1.java:31)
    i hope this will be more usefull and i know i write this info about db's version little bit late.
    J.

  • J2EE Struts - Database connection failed - help???:(

    Hello,
    I have built a little web application and it works without any problems. In the next step I tried to add a database connection but I have already worked on it for at least one day and I could not fix the problem with the database connection.
    I downloaded the MySQL Server 5.0 and installed it, furthermore I have downloaded the jdbc driver mysql-connector-java-3.1.11.zip and extracted it to the MySQL Server 5.0 directory. Furthermore I have added under system settings - system - etended - system variables the whole path to the driver -> C:\Programme\MySQL\MySQL Server 5.0\mysql-connector-java-3.1.11\mysql-connector-java-3.1.11-bin.jar to the CLASSPATH systemvariable.
    Then I have startet the SQL Server 5.0 with mysqld --console from the command line.
    Furthermore I have added under Project-Properties-Java Build Path - Libraries - Add External JARs in Eclipse the mysql-connector-java-3.1.11-bin.jar to my Struts WebProject.
    To test the whole thing I have added to the existing test-database from mysql a table named owner and wanted to test the database connection in the Action-class with the following statements - I quote the whole execute method of the OwnerAction class:
    public ActionForward execute(
                     ActionMapping mapping,
                     ActionForm form,
                     HttpServletRequest request,
                     HttpServletResponse response)
                     throws Exception {
                   OwnerForm ownerForm = (OwnerForm) form;
                   String greet = ownerForm.getGreet();
                   String name = ownerForm.getName();
                   request.setAttribute("name", name);
                   request.setAttribute("greet", greet);
                   String address = ownerForm.getAddress();
                   String email = ownerForm.getEmail();
                   int tel = ownerForm.getTel();
                   Connection conn = null;
                   Statement stmt = null;
                   ResultSet rs = null;
                   DriverManager.registerDriver(new org.gjt.mm.mysql.Driver());
                   conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","sa");
                   try {
                         //conn = dataSource.getConnection();
                         stmt = conn.createStatement();
                         int id = 0;
                         rs = stmt.executeQuery("select max(id) as counter from owner");
                         while(rs.next()){
                            id = rs.getInt("counter");
                         id += 1;
                         stmt.executeUpdate("insert into owner values("+id+", '"+greet+"', '"+name+"', '"+email+"', '"+address+"', "+tel+")");
                         rs.close();
                         stmt.close();
                         conn.close();
                      catch(SQLException e){
                         throw new SQLException("database error");
                      // Forward control to the specified success target
                      return (mapping.findForward("success"));
          }But when I execute the WebApplication and the Action will be called the following error message appears in the browser:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    root cause
    java.lang.NoClassDefFoundError: org/gjt/mm/mysql/Driver
         com.asprise.struts.action.OwnerAction.execute(OwnerAction.java:72)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5 logs.
    It must depend with anything that the driver was not found but I have defined it in the CLASSPATH variable and added it to the Web-Project in eclispe.
    Has anybody an idea what I have else made wrong or have forgotten??:(:(:(
    thanks in advance
    lg
    pat

    One thing I have forgotten - I have also copied the mysql-connector-java-3.1.11-bin.jar in the WebRoot\WEB-INF\lib directory of my EasyStruts WebApplication.
    Can anything else be wrong??:(:((
    regards

  • J2EE - database connection failed...:(:(:(

    Hello,
    I have built a little web application and it works without any problems. In the next step I tried to add a database connection but I have already worked on it for at least one day and I could not fix the problem with the database connection.
    I downloaded the MySQL Server 5.0 and installed it, furthermore I have downloaded the jdbc driver mysql-connector-java-3.1.11.zip and extracted it to the MySQL Server 5.0 directory. Furthermore I have added under system settings - system - etended - system variables the whole path to the driver -> C:\Programme\MySQL\MySQL Server 5.0\mysql-connector-java-3.1.11\mysql-connector-java-3.1.11-bin.jar to the CLASSPATH systemvariable.
    Then I have startet the SQL Server 5.0 with mysqld --console from the command line.
    Furthermore I have added under Project-Properties-Java Build Path - Libraries - Add External JARs in Eclipse the mysql-connector-java-3.1.11-bin.jar to my Struts WebProject.
    To test the whole thing I have added to the existing test-database from mysql a table named owner and wanted to test the database connection in the Action-class with the following statements - I quote the whole execute method of the OwnerAction class:
    public ActionForward execute(
                     ActionMapping mapping,
                     ActionForm form,
                     HttpServletRequest request,
                     HttpServletResponse response)
                     throws Exception {
                   OwnerForm ownerForm = (OwnerForm) form;
                   String greet = ownerForm.getGreet();
                   String name = ownerForm.getName();
                   request.setAttribute("name", name);
                   request.setAttribute("greet", greet);
                   String address = ownerForm.getAddress();
                   String email = ownerForm.getEmail();
                   int tel = ownerForm.getTel();
                   Connection conn = null;
                   Statement stmt = null;
                   ResultSet rs = null;
                   DriverManager.registerDriver(new org.gjt.mm.mysql.Driver());
                   conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","sa");
                   try {
                         //conn = dataSource.getConnection();
                         stmt = conn.createStatement();
                         int id = 0;
                         rs = stmt.executeQuery("select max(id) as counter from owner");
                         while(rs.next()){
                            id = rs.getInt("counter");
                         id += 1;
                         stmt.executeUpdate("insert into owner values("+id+", '"+greet+"', '"+name+"', '"+email+"', '"+address+"', "+tel+")");
                         rs.close();
                         stmt.close();
                         conn.close();
                      catch(SQLException e){
                         throw new SQLException("database error");
                      // Forward control to the specified success target
                      return (mapping.findForward("success"));
          }But when I execute the WebApplication and the Action will be called the following error message appears in the browser:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    root cause
    java.lang.NoClassDefFoundError: org/gjt/mm/mysql/Driver
         com.asprise.struts.action.OwnerAction.execute(OwnerAction.java:72)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5 logs.
    It must depend with anything that the driver was not found but I have defined it in the CLASSPATH variable and added it to the Web-Project in eclispe.
    Has anybody an idea what I have else made wrong or have forgotten??:(:(:(
    thanks in advance
    lg
    pat

    One thing I have forgotten - I have also copied the mysql-connector-java-3.1.11-bin.jar in the WebRoot\WEB-INF\lib directory of my EasyStruts WebApplication.
    Can anything else be wrong??:(:((
    regards

  • A database connection in a swing application

    hi ,
    i am developping an intranet stabdalone swing application based on a jdbc connection to oracle8i data server.
    in fact i am interested in keeping my user authentification encrypted while this connection is done! is there any method to do it ! i read about SSL but is it supported by web application ! i have a client-server simple connection !
    please help !

    Hello Levi,
    You can to do this form:
    String appModule = "yourAppmodule";
    String config = "yourAppmodule"+ "Local";
    ApplicationModule am = Configuration.createRootApplicationModule(appModule, config);
    ConnectionMetada cm = am.getTransaction().getConnectionMetadata();
    DriverManager.registerDriver(new OracleDriver());
    Connection connection = DriverManager.getConnection(cm.getJdbcURL());You can to see this threads:
    Retrieve Database Connection
    Getting the Connection object out of ApplicationModule
    Regards,
    Renan

  • Open and close database connection jsp page

    hi there, i wanna know about how to open database connection to Mysql at the beginning of the page and close the connection at the end of the page. The jsp page contain all processing code.
    plz help me...thx thx

    <html>
    <head>
    <basefont face="Arial">
    </head>
    <body>
    <%@ page language="java" import="java.sql.*" %>
    <%!
    // define variables
    String id;
    String firstName;
    String lastName;
    // define database parameters, change this according to your needs
    String host="localhost";
    String user="root";
    String pass="";
    String db="test";
    String conn;
    %>
    <table border="1" cellspacing="1" cellpadding="5">
    <tr>
    <td><b>id</b></td>
    <td><b>first name</b></td>
    <td><b>last name</b></td>
    </tr>
    <%
    Class.forName("org.gjt.mm.mysql.Driver");
    // create connection string
    conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user 
    + "&password=" + pass;
    // pass database parameters to JDBC driver
    Connection Conn = DriverManager.getConnection(conn);
    // query statement
    Statement SQLStatement = Conn.createStatement();
    // generate query
    // change this query according to your needs
    String Query = "SELECT id, firstname, lastname FROM abook";
    // get result
    ResultSet SQLResult = SQLStatement.executeQuery(Query);
    while(SQLResult.next())
       id = SQLResult.getString("id");
       firstName = SQLResult.getString("firstname");
       lastName = SQLResult.getString("lastname");
            out.println("<tr><td>" + id + "</td><td>" + 
         firstName + "</td><td>" + lastName + "</td></tr>");
    // close connection
    SQLResult.close();
    SQLStatement.close();
    Conn.close();
    %>
    </table>
    </body>
    </html>hi :-)
    i've got that on the net as part of the tutorial on jsp (long long time ago)
    you just have to be resourceful in finding solutions :-)
    try google :-) there are lot's of tutorial available in there ;-)
    goodluck ;-)
    regards,

  • Database connection in a WebDynpro Application - urgent

    Hi
    I am facing a problem with database connection. I am trying to develop a normal webdynpro application.
    I want to retrieve data from a table and show it.
    But my query is not giving the expected output. It is not even raising errors.
    Please give me an answer
    Thanks & regards
    Aparnna

    Connection con=null;
      Statement st=null;
      ResultSet rs=null;
    public void wdDoInit()
        //@@begin wdDoInit()
    try
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      con = DriverManager.getConnection("jdbc:odbc:erdsn","root","enteg123");
      st=con.createStatement();
        catch(Exception e){
        //@@end
    public void onActiononClickLogin(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActiononClickLogin(ServerEvent)
         String desig=null;
    try{
    rs = st.executeQuery("select *  from Login where Empid like uid and Pword like pw");
        if(rs.next()){
               desig=rs.getString("Designation");
         wdComponentAPI.getComponent().getMessageManager().reportSuccess(desig);
        if(desig.equalsIgnoreCase("Employee")){
              wdThis.wdFirePlugEmpOutPlug();
         else
         wdComponentAPI.getComponent().getMessageManager().reportWarning("Invalid input!");
          }catch(Exception e){

  • How to access  database connection from datatsource in a standalone java ap

    My java standalone application wants connection to database with lookup to datasource name which is configured in the oc4j app server.
    Please guide me with some ideas to acheieve this.

    user510497,
    Following sample program requires access to classes in "oc4j.jar" file.
    Test environment:
    * Server:
    + OC4J stand-alone 10.1.2.0.2
    + Red Hat Enterprise Linux AS release 3
    + Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    + Oracle Database 10g Release 10.1.0.4.0 - 64bit Production
    * Client
    + Microsoft Windows XP Professional Version 2002 Service Pack 2
    + Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    import java.sql.SQLException;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    public class DataSrc2 {
      public static void main(String[] args) {
        Connection conn = null;
        Properties l_props = new Properties();
        l_props.put(Context.INITIAL_CONTEXT_FACTORY,
                    "com.evermind.server.rmi.RMIInitialContextFactory");
        l_props.put(Context.PROVIDER_URL, "ormi://your_OC4J_host/");
        l_props.put(Context.SECURITY_PRINCIPAL, "your_OC4J_user");
        l_props.put(Context.SECURITY_CREDENTIALS, "your_OC4J_password");
        Context l_jndiContext = null;
        try {
          l_jndiContext = new InitialContext(l_props);
          Object l_obj = l_jndiContext.lookup("default-data-source");
          DataSource ds = (DataSource) l_obj;
          conn = ds.getConnection("scott","tiger");
          DatabaseMetaData dbmd = conn.getMetaData();
          System.out.println(dbmd.getDatabaseProductVersion());
        catch (NamingException x_naming) {
          x_naming.printStackTrace();
        catch (SQLException xSql) {
          xSql.printStackTrace();
        finally {
          if (l_jndiContext != null) {
            try {
              l_jndiContext.close();
            catch (NamingException x_naming) {
              System.err.println("Failed to close JNDI context.");
              x_naming.printStackTrace();
          if (conn != null) {
            try {
              conn.close();
            catch (SQLException xSql) {
              System.err.println("Failed to close [database] connection.");
              xSql.printStackTrace();
    }NOTES:
    1. Datasource lookup name is value of "default-data-source" attribute of "orion-application" element in file:
    <OC4J_HOME>/j2ee/home/config/application.xmlGood Luck,
    Avi.

  • How database connection pooling works in a application

    Hi Guys,
    I am new to Java and looking into best way of doing J2ee database conectivity. I am using Eclipse galileo3.5 J2EE with Mysql database and Tomcate 6.0.
    I am developing an email application where I need to implement MVC model for my webapplication, using jsp for presentation, servlet for control and java beans for model.
    I came across two tutorial for database connection pooling as given below.
    Eclipse Corner Article: Creating Database Web Applications with Eclipse - In this tutorial connection pooling is configure in Tomcate 6.0
    It says Copy and paste the following into your context.xml file (you may have to click on the Source tab at the bottom of the editor to be able to paste). This defines a DataSource with the name "jdbc/SampleDB". Our application will retrieve database connections from the pool using this name.
    <?xml version="1.0" encoding="UTF-8"?>
    <Context>
    <Resource name="jdbc/SampleDB" auth="Container"
    type="javax.sql.DataSource"
    username="app" password="app"
    driverClassName="org.apache.derby.jdbc.ClientDrive r"
    url="jdbc:derby://localhost:1527/sample"
    maxActive="8" />
    </Context>
    Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
    It uses java bean for connection pooling and then use straight way in JSP and no Servlet used.
    conpool.jsp
    <%@page import="java.sql.Connection"%>
    <jsp:useBean id="pl" class="com.CoreJava.ConnectionPooling"/>
    <% Connection con = pl.getConnection(); %>
    //do something using con
    connectionPooling.java
    import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolD ataSource;
    public class ConnectionPooling
    static Connection con=null;
    public static Connection getConnection()
    try
    MysqlConnectionPoolDataSource po=new MysqlConnectionPoolDataSource();
    po.setServerName("localhost");
    po.setPortNumber(3306);
    po.setDatabaseName("mydatabase"); //changeur database name
    po.setUser("root");//ur username
    po.setPassword("");//ur password
    con = po.getConnection();
    catch(Exception e)
    System.out.println("Exception Connection :"+e);
    return con;
    Please some one explain which is the best way of doing connection pooling to the database by using MVC pattern
    Please if some one advise me how to use MVC architecture for simple email application and database connectivty.
    Thanks

    >
    >
    Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
    Never EVER use roseindia. It is terrible shit.
    [http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html]
    The correct answer is what you found in the eclipse article. And you can read the Tomcat docs for more.
    As per usual the code you have posted from Roseindia is a big pile of rubbish that was written by a complete idiot. I mean the person who wrote it apparently doesn't know much Java at all. Let alone JDBC. Or Connection pools. Or J2EE. It's not the worst I've seen from them but it's pretty bad.

  • Problem in getting the database connection from a connection pool

    Hai All,
    I am facing a problem in getting the database connection from a connection pool created on weblogic server 8.1.
    I am using the Oracle database 8.1.7.
    I have configured my connection pool, datasource and JNDI in weblogic.
    In my java program i have the following code to retrieve the connection.
    import java.sql.*;    
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    class jdbcshp1 {
        public static void main(String[] args) {
         Connection connection = null;
         try {
               Hashtable ht = new Hashtable();
               ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");  // Wanna get rid of this.
               ht.put(Context.PROVIDER_URL,"t3://localhost:7001"); // wanna get rid of this.
               // Get a context for the JNDI look up
               Context ctx = new InitialContext(ht);
            javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("myjndi1");
              //Create a connection object
              connection = ds.getConnection();
         The above code is working fine but, the two ht.put statements are creating problem.
    The problem is, after converting the application into WAR file it can be deployed
    on any machine or different port on same machine. My application fails if its deployed on
    weglogicserver which is at different port.
    Is there any way that i can get rid of those ht.put statements or any other way to solve the problem.
    any help is appreciated.
    Thanks in advance
    Pooja.

    Hai All,
    Firstly, thanks for ur reply.
    Even i have seen some code which uses context constructor with out any parameter and works fine.
    i dont understand why its not working for my code.
    When i remove those ht.put code and use context constructor with out any parameter, it giving an error.
    Context ctx = new InitialContext();
    javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("ocjndi");
    connection = ds.getConnection();The error is as follows:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    the above error is forcing me to include those code but if the port number is changed the code will not work. Plz let meknow if some setting have to be made.
    I appreciate all ur valuable help.
    Thanks once again.
    Pooja.

Maybe you are looking for

  • Open directory and Active directory

    Hello everyone. I am from a school in london. We currently have 8 servers (7 running Server 2003 and a recently installed Mac server running os x server 10.5) We have recently installed new macs into our media room and need them to be set up to work

  • Is it possible to send SMS through java

    Hi all I m a student and as a part of my project I need to create an SMS server(SMS gateway). Can we send SMS through Java and if yes then send me the code for the same . Also on which GSM Modem will it Work , I've heard about Nokia GSM Modem N32. Ki

  • Photoshop Elements 11 cannot find Qtcore4.dll

    Photoshop Elements 11 cannot find Qtcore4.dll. I have removed the program and re-installed twice and have run sfc/scannow. I still get the error on starting the program. A web search does not give any definite answers

  • TS3406 Twice call from same number if not done anything, the screen is locked

    Iso 7.0.4 - Twice call from  same number (within 3 minutes) if not done anything immediately after the first call, the screen is locked (the added photo of screen). Now no way to access the phone of home screen or something else. iso 7.0.4 - Twice ca

  • Perfectly good XML file no longer updating in iTunes

    Hey there, forum. Ok, so I have this podcast that has sucessfully updated 36 or so times, I've never had a problem until now. The podcast XML file is updating just like it has been, and and I can go to http://www.imboredpictures.com/e78podcastfeed.xm