Java.sql.connection problems

Hi, I hav got this problem:
PRB 1
I have got the JDBC connection established with the OracleDataSource instance on my java application
I wonder if there is a way to check the connection if it is still alive. any hint? i tried connection.isClosed() but that doesn't help.
PRB 2
I am in this scenario:
The connection is established during application start and something goes wrong say like the DB server goes offline in the middle of no where and I do a commit / rollback. I will get a SQLExeption called. But right after the db comes back online.. i tried to do a commit / rollback, the SQLExeption is still persist.
Q1. Does this mean that when the exception is caught, my connection would no longer be valid and I need to restart the application?
Q2. could i reinitialize the connection after the exception to avoid the restart?
Thank you.

Hi, I hav got this problem:
PRB 1
I have got the JDBC connection established with the
OracleDataSource instance on my java application
I wonder if there is a way to check the connection if
it is still alive. any hint? i tried
connection.isClosed() but that doesn't help.From Java APIs reg. isClosed():This method is guaranteed to return true only when it is called after the method Connection.close has been called.
This method generally cannot be called to determine whether a connection to a database is valid or invalid. A typical client can determine that a connection is invalid by catching any exceptions that might be thrown when an operation is attempted.
PRB 2
I am in this scenario:
The connection is established during application start
and something goes wrong say like the DB server goes
offline in the middle of no where and I do a commit /
rollback. I will get a SQLExeption called. But right
after the db comes back online.. i tried to do a
commit / rollback, the SQLExeption is still persist.
Q1. Does this mean that when the exception is caught,
my connection would no longer be valid and I need to
restart the application?
Q2. could i reinitialize the connection after the
exception to avoid the restart?Once your DB goes down, your connection is broken. You cannot do anything with that connection...like Rollback, commit etc. You need to re-establish the connection. You don't need to restart the application, but you might want to check if the connection is null. If it is, you might have to try a new connection. Probably, your application can quit trying for a connection after 'x' number of attempts.
Kumar

Similar Messages

  • What is the recommended way to get a java.sql.Connection to the DB  for ADF

    How do I create a standalone database connection based on the datasource setup in ADF?
    I have seen code like this in a method of AppModuleImpl.java but that seems a bit of a hack.
    Connection conn = this.getDBTransaction().createStatement(0).getConnection();
    What I need is a java.sql.Connection to the database used in the application module so I can call PL/SQL code and or work with AQ queues.
    I would prefer a separate connection from the one used by the ADF model so it can have its own transaction control etc.
    But I would like to get the connection created authenticated based on regular datasource setup.

    http://www.oracle.com/webfolder/technetwork/jdeveloper/howto/11114/managedserver/wlsadfms.html#8c
    https://blogs.oracle.com/jdevotnharvest/entry/accessing_weblogic_jdbc_datasource_from

  • Java.sql.Connection x J9 VM

    Is possible to use class java.util.Connection with J9 VM using CDC/PP ?
    Logging:
    java.lang.NoClassDefFoundError: java.sql.Connection
    at java.lang.Class.verifyImpl(NativeMethod)
    Help me please;
    Thanks
    []'s

    Is possible to use class java.util.Connection with J9 VM using CDC/PP ?Yes. Check your classpath JARs for java.sql.Connection. You may be missing the jar "database_enabler.jar". See:
    http://blog.vikdavid.com/2005/08/troubleshooting.html
    Vik

  • Can't we pass java.sql.Connection as parameter toDatum() method

    I am in mid of java 1.3 to 1.4 migration, now I am getting the below error.can't we pass java.sql.Connection as a param to toDatum(), but I did the same before for another module and it worked fine, now I am getting the error.
    any changes need to be done?
    [b]toDatum(oracle.jdbc.driver.OracleConnection,java.lang.String) in oracle.jpub.runtime.MutableArray cannot be applied to (java.sql.Connection,java.lang.String)
    return array.toDatum(c, SQL_NAME);
    ^
    1 error
    I changed to use
    import oracle.sql.ORAData;
    import oracle.sql.ORADataFactory;
    instead of
    import oracle.sql.CustomDatum;
    import oracle.sql.CustomDatumFactory;

    In general, it's bad practice to be that "open" with regards to parameters to methods, especially when using remote invocations. However, if you really, really, really, really need to - and I doubt you do - you can use Serializable for the type of parameter. But that's still inelegant and, well, raises all sorts of issues, starting with your design...

  • How to check whether java.sql.Connection has been dropped or not

    Hi,
    How can i check whether the connection is dropped from the database or not by using java.sql.Connection API.
    Thanks

    There's a few ways to check Connections, each with a different use:
    (1) conn.isOpen()
    (2) conn == null
    (3) the last one is a little more involved and adds some overhead. You can run SELECT 1 FROM dual; (Oracle) or SELECT 1 (MSSQL) and check for exceptions.
    The only way to check a connection, as far as I know, is to use it. That said, there must be a better way???

  • Not Converted : Free-hand SQL connection problem

    While converting a Free Hand SQL report from Desktop Intelligence to Web Intelligence report in BI XI 3.1, I am faced with the problem
    Not Converted : <REPNAME> - Free-hand SQL connection problem
    It is be noted that there are some other Free Hand SQL Reports, that go converted and published without any error. The subject report has two Data Providers; one referring to the Universe and other from the Free Hand SQL tagged to a DB Connection

    Ajay,
    Some more points that can be of consideration to you to help understand my problems.
    The conversion from DeskI to WebI is in the same version BI XI 3.1 and not to BI 4.0 in which Free Hand SQLs is not supported.
    I have converted one other Free Hand SQL Report with an error "Partially Converted : <REPNAME2> - Conditional or permanent Hide Header not available in Web Intelligence", for which I had to edit the report in InfoView and un-tick the "Show When Empty" property of the table ( http://www.forumtopics.com/busobj/viewtopic.php?t=197157&view=next&sid=e6840aafa2d1267c66dae164d1dbf9db ). I think the solution mentioned in this link does not meet the purpose as the table is not displayed in the design time after the above untick.
    Coming back to our issue, further probing into this aspect I stumbled upon this link meant for RCT for BI 4.0 version
    https://csdwportal.dhhs.state.nc.us/downloads/Business%20Objects%20XI%20R4.0%20Docs/SAP%20BusinessObjects%20Report%20Con…
    where in Section 3.4.9, there is a mention of the limitation in conversion as under
    "Conversion of reports with free-hand SQL or stored procedures is only possible in Connected mode, since the Report Conversion Tool needs to use the secured connection to the database that is saved in the CMS."
    I want to how the secured connection to the database in REPNAME2 is different from the subject report REPNAME1 as REPNAME2 got partially converted. The error reported for Subject report is "Free Hand SQL Connection Problem" and not conversion problem which can occur after the connection is established.
    I did check the security properties of various FHSQL connections in the CMC and all of them are identical in nature.
    Please advise

  • BC4J - How can I get java.sql.Connection ?

    Hi,
    I am using BC4J for my Application and want to get the java.sql.Connection from ApplicationModule or from anywhere such that I can use the same connection as in ApplicaitonModule, to do some work in the database.
    I tried to get it from the SessionInfo :
    sessioninfo.getConnectionInfo();
    but this returns me oracle.dacf.dataset.connections.Connection
    How can I convert this to java.sql.Connection?
    Or Is there any other means to get hold of sql.Connection?
    Any help would be appreciated.
    TIA

    Thanks for this reply.. but
    I need java.sql.Connection to call a stored procedure in Oracle database and I have to pass oracle.sql.ARRAY to it.
    My Stored Procedure looks like:
    create or replace PROCEDURE updateRevenueNetworkInfo(revid varchar2, netids Varchar32Array)
    where 'Varchar32Array' is my own datatype in the database which is mapped to oracle.sql.ARRAY object in java.
    And in order to create oracle.sql.ARRAY I need java.sql.Connection as shown below
    oracle.sql.ARRAY pTable = new oracle.sql.ARRAY(desc, connection, netidarray);
    I am executing my stored procedure like this:
    ArrayDescriptor desc = null; CallableStatement cs = null;
    String[] netidarray = {"00-AOL-T1-N003"};
    desc = ArrayDescriptor.createDescriptor("VARCHAR32ARRAY", conn);
    oracle.sql.ARRAY pTable = new ARRAY(desc, connection, netidarray);
    cs = conn.prepareCall( "BEGIN updaterevenuenetworkinfo(?,?); END;" );
    ((OracleCallableStatement)cs).setString(1,"00-AOL-T1-R3");
    ((OracleCallableStatement)cs).setArray(2, pTable);
    cs.execute();
    Is there any way of getting java.sql.Connection such that I can use the same connection as in the ApplicationModule?
    OR Is there any other way of passing Array of Strings to a stored procedure in the database?
    Thanks for the help.
    null

  • Java DB connectivity problems

    I need troubleshooting techniques how to deal with database connectivity problems.
    I am using netbean6m10, Java6.0_1b6 and my program reads these properties before opening the database.
    lsfbvol.db.url="jdbc:derby:/etsdDB/ds8300DB;create=yes"
    lsfbvol.db.driver=org.apache.derby.jdbc.EmbeddedDriver
    For debugging purposes, I printed the driver to ensure it was read properly and it was.
    DB Driver=org.apache.derby.jdbc.EmbeddedDriver
    Below is the captured exception. Please advice.
    Thanks
    Arsi
    java.sql.SQLException: No suitable driver found for "jdbc:derby:/etsdDB/ds8300DB;create=yes
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    ---SQLException Caught---
    SQLState: 08001
    Severity: 0
    Message: No suitable driver found for "jdbc:derby:/etsdDB/ds8300DB;create=yes
    at loadDB.MatchGroup.dbConnect(MatchGroup.java:458)
    at loadDB.RxProps.dbCreateTable(RxProps.java:308)
    at loadDB.RxProps.init(RxProps.java:122)
    at loadDB.RxProps.<init>(RxProps.java:97)
    at loadDB.File2DB.<init>(File2DB.java:58)
    at ds8300.Main.main(Main.java:33)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 3 seconds)

    Thanks for the response.
    This is a working program under MySQL and modified for a good practice to learn the new Java DB included in jdk6. Actually, all I changed was my property file which contained all the properties for URL and Driver for the DB.
    My URL was pointing to my working-directory which happend to be my flash-card. I changed it to my C drive but still is having same problem.
    About my driver not being loaded. My understanding was under jdk6 there was no need to load the driver for embeded Java DB because was already included into the system.
    Not sure what to try next. Please advice.
    Thanks. Arsi

  • Need help with a Java-SQL connection

    My classmates and I created a DesktopFrame. Within it are reports that require a connection to an MS Access Database. When a report in an InternalFrame is opened: the SQL command works, there is a connection, and everything goes well on the first run.
    However, when another InternalFrame is opened or when the same InternalFrame is opened the 2nd time, an error occurs. It produces a java.sql.SQLException: General Error.
    Can anyone help me? Thanks in advance.

    Provide more info, maybe even some code segments. (Not all). May be easier to help

  • SQL Connect problem - migration from Oracle 7.3.4 to Oracle 8.0.6

    Our development environment has just been upgraded from HP10.20
    to HP11 and the database from Oracle 7.3.4.0 to Oracle 8.0.6.0.
    I am now having problems with one of the PRO*C programs. The old
    executable( compiled in the old enviroment HP10/Oracle734) is
    working fine in the new environment. But after I successfully re-
    compiled this program in the new environment, the new executable
    is not working and stops at the statement: 'EXEC SQL CONNECT:
    userid'. I have checked the userid and Oracle settings, they are
    correct. Right after the EXEC SQL, I've tried checking the
    status of connection, but it never gets there. The
    only change to the make file is using
    $(ORACLE8_HOME)/precomp/lib/env_precomp.mk instead of using
    $(ORACLE7_HOME)/precomp/env_precomp.mk
    Other PRO*C programs which are using exactly the same connecting
    statemment are working fine.
    Anyone have any ideas, I would appreciate them?
    Thanks,

    I am upgrading with precisely the same varaibles that you encountered
    and am receiving the same inability to do a simple CONNECT with
    Pro*C. Were you able to resolve this problem? If so, please reply
    with some guidance.
    Thank you.
    - Tad Franson
    [email protected]

  • Coldfusion mx sql connection problem

    Hi guys,
    I just installed CF MX, but with Apache server, and it works
    fine. But, I can't get it to work with my MySQL databases. I have
    phpMyAdmin, and it works fine, but, I get the following error when
    I want to make a new Datasource using MySQL
    Connection verification failed for data source: testing
    []java.sql.SQLException: Communication failure during
    handshake. Is there a server running on localhost:3306?
    The root cause was that: java.sql.SQLException: Communication
    failure during handshake. Is there a server running on
    localhost:3306?
    SQL is running on 3306, so...what's wrong? I'm kinda stuck.
    Thanks in advance!

    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6ef0253
    HTH
    Tim Carley
    www.recfusion.com
    [email protected]

  • Access to java.sql.Connection objects

    Hi,
    The Kodo JDO developers guide states 2 methods to obtain a Connection
    object for the database.
    The first method makes use of a function getStoreManager(), which
    doesn't seem to exist anywhere and which is certainly not mentioned
    anywhere in the documentation.
    The second method makes use of a class DataSource, which also does not
    exist anywhere. I am aware that this class is present in JDK1.4 but we
    are using 1.3 and it states Kodo works on this version.
    Can anybody please clarify how I obtain a connection using these two
    methods?
    Lars

    On 7/1/02 9:15 AM, "Lars" <[email protected]> wrote:
    Hi,
    The Kodo JDO developers guide states 2 methods to obtain a Connection
    object for the database.
    The first method makes use of a function getStoreManager(), which
    doesn't seem to exist anywhere and which is certainly not mentioned
    anywhere in the documentation.getStoreManager() is a Kodo-specific method in
    com.solarmetric.kodo.runtime.PersistenceManagerImpl. The JavaDoc for this
    class is not available in Kodo JDO 2.2.x; it is available in Kodo JDO 2.3.0.
    The second method makes use of a class DataSource, which also does not
    exist anywhere. I am aware that this class is present in JDK1.4 but we
    are using 1.3 and it states Kodo works on this version.DataSource is part of the Java SQL standard extensions, in javax.sql. See
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/sql/DataSource.html for
    more documentation on it.
    Note that we do not require that you use a JDBC 2.0 driver (one that
    supports javax.sql). We provide our own implementation of DataSource that is
    used whenever a connection URL is specified. If you want to use your own
    connection pooling etc. with a JDBC 1.0 driver, then you will have to
    implement the DataSource interface on your own; we assume that the
    ConnectionFactory object implements the DataSource interface.
    -Patrick
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • SQL connectivity problem

    Hi to all,
    Can anybody resolve this eror i.e.
    Provider: named pipes Provider, error- 40 could not open the connection to the SQL Server.
    i have done a lot of search to resolve it but i could nt get a exact solution of this problem.Please it s humbly requested to you people please give me the solution of as soon as possible. Actually  i m doing my final project  in C#>NET with using SQL SERVER 2005 and have a very hsort time to complete the project but due to this problem i cannot go forward.Please reply me as soon as possible.
    I m waiting for your response
    Thanks in advance
    meerab

     System.Data.SqlClient.SqlEwception:An error has occurred while establishing
    a connection to the server.when connecting to SQL Server 2005,this failure
    may be causeed by the fact that under the default setting SQL serves dose not
    allow remote connection.(provider:Named Pipes Provider,40-could not open a
    connection SQL Server)
     at System.Data.SqlClient.SqlInternal Connection. OnError(SqlException exception, boolean breakConnection)
     at System.Data.sqlclient.TdsParser.TrowExceptionAndWarning(TdsstatObject stateObj)
     at System.Data.sqlclient.TdsParser.Connect(boolean& useFailoverPartner,boolean&failureDemandDone,String host,String
    failoverPartner,String protocol,SqlinternalConnectionTds connHandler,lnt64 timerExpire,boolean encrypt,boolean trustSearvCert,boolean
    integtedSecurity.SqlConnction owingObject,boolean aliasLookup)
     at System.Data.Sqlclient .SqlInternalConnectionTdat.openLogineEnlist(SqlConnection owingObject,SqlCooectionString connectionOption
    string newPassword,boolean redirectUserInstance)
     at System.Data.Sqlclient .SqlInternalConnectionTd.ctor(DbConnectionPoolIdentity identity,SqlConnectionString coonectionOption,object
    proviedInfo,StringnemPassword,Sqlconnection owingObject,boolean redirctedUserIntance)
     at System.Data.SqlconnectionFactory.creatConnectio(DbConnectionOption option ,ObjectpoolGroupProviedInfo,
    DPConnectionPool pool,Dbconnction owingConnection)
     at.System.Data.ProviderBase.DbConnectionFactory.CreatpooledConnecton(DbConnection owwingConnection,DBConnectionPool pool,
    DbConnectionOptions option
     at system.Data.ProviderBase.DbCnnectionPool.CreatObject(dpConnection owingObject)
     at system.Data.ProviderBase.DbCnnectionPool.UsercreatRequeest(DbConnection owingObject)
     at system.Data.ProviderBase.DbCnnectionPool.GetConnection(DbConnection owningobject)
    at system.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory 0
    at System.Data.SqlClient.SqlConnection.Open()
    at DAL.Class1.srh(string item_name)in C:\Documents and settings\star\Desktop\final_project\Solution\DAL\Class1.cs:line 80
    It s the complete error message. i Hope u ll understand it, now.
    I m waitng for ur response.............
    Thanks in advance.

  • Sql connecting problem form ip of local server

    hello sir 
    i have counfigured sql server 2008 r2
    when iconnect sql database engine using  ip\"instance name" it show me error  (ip address of local server)
    i got same error when i am connecting only ip without insatbce name "cannot connect to (ip)"
    but i can connect with .\"incatance name"  and  
    "pc name"\"instance name"
    i need to access from ip\"inctance name"
    any one have this type of solutions ?
    then plz help me
    i have also check this options
    http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx

    Hi,
    Try below links:
    http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ed7b78c0-7dcb-4be7-96fa-f85b74f0e413/sql-network-interfaces-error-26-error-locating-serverinstance-specified
    http://stackoverflow.com/questions/13754563/sql-network-interfaces-error-26-error-locating-server-instance-specified
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

  • Exception in method createStatement() of java.sql.Connection

    Hi,
    When creating a statement :
    Statement stat = conn.createStatement();
    I got this error:
    java.lang.NegativeArraySizeExceptionoracle.net.ano.CryptoDataPacket.decryptAndChecksum(CryptoDataPacket)
    oracle.net.ano.CryptoDataPacket.<init>(CryptoDataPacket)
    oracle.net.ano.AnoNetInputStream.processPacket(AnoNetInputStream)
    oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
    oracle.net.ns.NetInputStream.read(Unknown Source)
    oracle.net.ns.NetInputStream.read(Unknown Source)
    oracle.net.ns.NetInputStream.read(Unknown Source)
    oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:728)
    oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:700)
    oracle.jdbc.ttc7.Oopen.receive(Oopen.java:103)
    oracle.jdbc.ttc7.TTC7Protocol.open(TTC7Protocol.java:497)
    oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:505)
    oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConnection.java:693)
    oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection.java:570)
    Any idea of what is the problem?
    Thanks in advance,
    Karim

    Hi,
    I am trying to open service browser in Test tools to test entity service.But Service browser is not opening and i am getting 'access forbidden'.Can you please help to resolve this issue.And what role i have to add for CAF user/developer.
    Thanks,
    Murthy.

Maybe you are looking for

  • How can I create a "Camera Shot" list report?

    Adobe Story allows you to annotate a script with "Camera Shots", but where is the facility to index and print these out as a list?

  • How to block a particular UOM in SRM?

    Hi All, We have integrated SRM with Baan through XI. For a particular company code in Baan, we have not maintained the UOM 'CARD'. I checked in txn. CUNI in SRM system and UOM 'CARD' is there, but it is not specific to any company code. When user is

  • Not able to connect through Toad

    Hi I installed Toad. As soon as i tried to create new connection it shows a screec with Database<drop down> but at present i don't have any database. But it is showing two values in that 'EXTPROC_CONNECTION_DATA','PERENCO'. I don't from where these a

  • ORACLE in XML component

    Any suggestions please. I have just discovered the XML component and have some work which I want to do with XML. Is it possible to get the style sheet to work on the result of the <ORACLE></ORACLE> action? Can it do anything with this sort of instruc

  • I'm fed up...someone he

    OK guys, I promise I will do exactly everything you tell me to do. First off, I have Windows 98SE and when I use CreativeSource I try to put music onto my Creative Zen Micro but it is obviously not connected. When I go to My Computer and click Media