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???

Similar Messages

  • How to identify whether a TransientVO value has been changed or not on jsff

    Hi
    I have a TransientVO view object dragged onto jsff page. Is there any way to identify in backing bean or in Application Module to identify whether there is any attribute value has been modified or not?
    Thanks in advance !!

    Hi:
    My understanding is that's ADF's internal business to keep track of RowSet changes. In your code, it's not expensive to explicitly call commit OperationBinding. When your code issue an explicit commit, ADF will check if a real commit necessary or not. If any row or attribute changed, a real commit will happen.
    If your application really want to get notified when any attribute changes, and you feel it too much to implement a valueChangeListener for every inputText, you should try a more generic one: rowUpdated(). I never use this one, but according to the manual, your probably can set a flag in your overwritten rowUpdated to flag an attribute value change when it happens.
    But I really recommend you simply issue a commit and let ADF decide the necessity of a real commit. If you are really interested in which specific field changes, to me you have only 2 options, 1 is to do valueChangeListener, the other is try to figure out if rowUpdated() helps.
    If you feel my answer helps, please mark it as 'helpful'; If it is correct, please mark it as 'correct'.
    Thanks,
    Alex

  • How to check whether a Document in KM is classified or not using JAVA API

    Hello Everyone,
      Can anyone tell me, How to check whether a Document in KM is classified or not, using JAVA API's??
    Thanks & Regards,
    Adren D'Souza

    Hi,
    The code is as follows:
    IIndexService indexService = null;
    try {
       indexService = (IIndexService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.INDEX_SERVICE);
    } catch (ResourceException e) {
       if (indexService == null) {
         log.errorT("Error on instanciating the index service");
         return this.renderMessage(this.getBundleString(RES_NO_INDEX_SERVICE), StatusType.ERROR);
    // get index
    IIndex index = null;
    try {
       index = indexService.getIndex("YourIndexID");
    } catch (WcmException e1) {
       log.errorT("Error when trying to get the index");
       return this.renderMessage(this.getBundleString(RES_NO_INDEX), StatusType.ERROR);
    // check if the index is a instance of AbstractClassificationIndex
    AbstractClassificationIndex classiIndex = null;
    if (index instanceof AbstractClassificationIndex) {
       classiIndex = (AbstractClassificationIndex) index;
    } else {
       log.errorT("The index " + index.getIndexName() + " is no classification index");
       return this.renderMessage(this.getBundleString(RES_NO_CLASSIFICATION_INDEX), StatusType.WARNING);
    //give your KM Resource here for which you want to know if it is classified or not
    boolean classified = classiIndex.isDocClassifiedInAnyTax(resource);
    Regards,
    Praveen Gudapati

  • How to check whether my iphone 5 is factory unlocked or not??

    how to check whether my iphone 5 is factory unlocked or not??

    Did you buy it unlocked at full, non-subsidised price?  If not, then it's not unlocked.

  • HT201653 We are a retail shop which has a copy of AppleCare Protection plan. The box is not sealed. How can I tell if the product has been registered or not.

    We are a retail shop which has a copy of AppleCare Protection plan. The box is not sealed. How can I tell if the product has been registered or not.

    Since the only thing needed in that box is the small piece of paper with the (very long) registration code on it (usually found inside the booklet), see if that is actually there and, if it is, call Apple at 800-275-2273 and ask to be transferred to the Applecare department. Here is the link to the Applecare plan - just in case you may need it, see the fax numbers listed under para. 9 (Cancellation).
    http://www.apple.com/legal/sales-support/applecare/appmacnaen.html

  • 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

  • Is there a way to check whether an Excel file has a header or not?

    Hi!
    I'm currently using POI Utility to read and write Excel files.
    You normally use the HasHeaderRow = true / false to specify whether the file has a header or not.
    Now, let's say I have a program that needs to read Excel files from a directory, some have headers, some don't.
    Is there a way to know dynamically whether a header has been defined or not?
    Then, for those having headers, the flag will be set as true, while for those which don't have any header, the flag will be set as false.
    E.g.
    <!--- Create an instance of the POIUtility.cfc. --->
        <cfset objPOI = CreateObject(
            "component",
            "POIUtility"
            ).Init()
            />
    <!--- Set directory --->
    <cfset currentDirectory = GetDirectoryFromPath(GetTemplatePath()) & "newDir">
    <!--- Check whether the directory exists. --->
    <cfif DirectoryExists(variables.currentDirectory)>
         <!--- Read files from the specified directory --->
         <cfdirectory action="list" directory="#variables.currentDirectory#" type="file" filter="*.xls" name="qDirectory">
         <!--- Check if the directory has any Excel file --->
         <cfif variables.qDirectory.recordcount gt 0>
              <!--- Loop query --->
         <cfloop query="variables.qDirectory">
                   <!--- Check if header is present in each of the file --->
                        IF headerExists THEN
                             headerFlag = true
                        ELSE
                             headerFlag = false
                        END IF
                   <!--- Read Excel File --->
                <cfset objSheet = objPOI.ReadExcel(FilePath = #variables.qDirectory.name#, HasHeaderRow = #variables.headerFlag#, SheetIndex = 0) />
              </cfloop>
         </cfif>
    </cfif>
    Any help would be most welcome.
    Thanks and regards,
    Yogesh Mahadnac  

    Hi cfSearching,
    Many thanks for your reply! I really do appreciate!
    However, I've still got 1 more question for you.
    At the moment, I'm using POI and sometimes cfx_Excel2Query to read Excel files.
    In both cases, you have to specify whether the first row is a header.
    How would you read the Excel file to check whether the 1st row is the header?
    I've tried using cffile, but I get all sorts of "garbage"
            <cffile action="read" file="#variables.filename#" variable="xlsResult">
            <cfloop index="i" list="#variables.xlsResult#" delimiters="#chr(13)#&#chr(10)#">
                <cfif variables.i eq 1>
                    <cfoutput>
                        Test 1st Row: #trim(replacenocase(listgetat(variables.i,1,","),'"',"","All"))#
                    </cfoutput>
                </cfif>
            </cfloop>
    I get the following output:
    ÐÏ à¡± á����.... etc etc
    I'd be very much grateful if you could please advise on the latter at your earliest convenience.
    Thanks and best regards,
    Yogesh Mahadnac

  • How to check the sales order that has been PGI from a range of dates.

    Hi SAP Gurus,
    I have a query on how can I check the sales order that has been PGI from a range of dates in SAP?
    Thanks,
    Madelyn

    Dear Madelyn
    Go to VA05, give the date range and execute.  List of sale orders will be generated.  There you can see a tab "Status"  in which, the status would be like
    -  Not delivered
    -  Partially delivered
    So based on this, you can decide whether the order is still open or completed.
    thanks
    G. Lakshmipathi

  • How to check whether a char string is in uppercase or not

    Hi,
    I know how to convert strings to change strings to uppercase or lowercase, but is there any function to check, beforehand, if the field is in uppercase, for instance ? The intention here is simply to spare processing in situations where the string is already in uppercase, and thus not needing any further processing (given I want to turn the string into uppercase.)
    Thanks in advance,
    Avraham

    Hi Avraham ,
    To check whether the string is in upper case or not use CA keyward.
    To check  try the following code  ---
    DATA : W_STRING(5) TYPE C,
    W_ABCDE(26) TYPE C VALUE 'abcdefghijklmnopqrstuvwxyz'.
    w_string = 'abcd'.
    IF W_STRING CA W_ABCDE.
    TRANSLATE w_string TO UPPER CASE.
    ELSE.
    MESSAGE 'It is a uppercase string' TYPE 'S'.
    ENDIF.
    Try this link  this will definitely help you -
    https://wiki.sdn.sap.com/wiki/display/ABAP/Validationofastringintermsof+case
    Regards
    Pinaki

  • How to check remotely that a PC has been restarted after Labview Runtime 2011 has been installed on it?

    Hello,
    I am deploying a Labview 2011 application on 150 XP-machines in various plants worldwide. Currently all machines still have an old Labview 8.21 runtime (+old DAQmx). I have sent a procedure to my colleagues in the plants so that they install the new runtime (+ new DAQmx). On my side I have built a code to check from my Pc if a certain registry key is present on the 150 PCs which tells me that the new installer ran or not.
    The key that I found is:
    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\Installer\Products\1C5E801AE54C4AE43A59FC169F95CA28]
    "ProductName"="NI-DAQmx MAX Configuration Support 9.3.5"
    "PackageCode"="61EEAEC207A28A842B3341ED6809453D"
    "Language"=dword:00000009
    "Version"=dword:0923c001
    "Assignment"=dword:00000001
    "AdvertiseFlags"=dword:00000184
    "InstanceType"=dword:00000000
    "AuthorizedLUAApp"=dword:00000000
    "Clients"=hex(7):3a,00,00,00,00,00
    This works well but it does not tell me that the PC has restarted after the installer has been run. If I do not restart the PC and try to execute my Labview 2011 executable I get a long error message (NIDAQmx not registered,...).
    As it seems difficult to get the properties of a key to know when it was installed I was rather leaning towards checking if a certain DLL (?) has been registered or not. But it is just a vague idea and I do not know how to put that in place.
    I am attaching the current code that I have and that works well but cannot make the difference between Labview 2011 runtime installed and PC restarted or not.
    Thanks for the help
    Christophe
    Solved!
    Go to Solution.
    Attachments:
    Check Remote Registry Key.vi ‏45 KB

    You might look for a file that would be created as part of installation to determine the install date/time (ini or other support file created as part of runtime install)
    Combine that with a query of the station's uptime and you could calculate if the station has been up longer than the time since the install. Not perfect, but should be possible...
    http://en.wikipedia.org/wiki/Uptime#Using_WMI
    wmic /node:"my-server" os get lastbootuptime
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How to check if a function module has been called dynamically in programs

    Hi,
    I wanted to know if there is a way to check if a function module has been called dynamically in any programs. In SE37, if you click on where used list for a FM, it shows FM not found in programs (Possibly dynamic calls).
    I am checking if the function module /SDF/RBE_EXECUTE_SQL_WRAPPER has been used in any of SAP programs. Your help is greatly appreciated.
    Best regards,
    Siva

    one way will using program RPR_ABAP_SOURCE_SCAN search for complete source codes with a find string RBE_EXECUTE_SQL_WRAPPER .
    PS But it the function module name comes from a table ( Table entry value) then it is difficult to find

  • How to check whether Java 3d is using hardware acceleration?

    Hi
    I just started looking into Java3d api. I am going through the tutorial examples. When I run it on Windows with JDK1.4.2, the app runs, but taskmanager shows cpu usage is around 55% of my 3GHz Intel processor.
    I am sending the following VM parameters
    -Djava.library.path=C:\progra~1\Java\Java3D\bin -Dj3d.rend=ogl -Dj3d.debug=true
    I tried Direct3D as well by passing -Dj3d.rend=d3d. I don't see much difference in cpu usage. The sample I am playing is the one where you create a ColorCube and rotate it on a timeline. Pretty straight forward code taken from the tutorial.
    I am wondering
    a) Why is my cpu at 55% if it is using h/w acceleration?
    b) Is there any way to find out whether Java is using software renderer vs h/w renderer.
    I used sys internals processexp tool to look at the stack of java thread that is spinning the cube. I don't see any references to opengl or j3d dlls in the call stack.
    I appreciate ur help.
    Thanks

    check this link, it queries the properties of your system:
    http://download.java.net/media/java3d/webstart/test/QueryProperties.jnlp

  • How to check whether weblogic server is in DEBUG mode or not

    Hi
    I want to check in my OSB proxy whether weblogic server is in Debug mode or not?
    IF abv thing is not possible ,
    I have check whether server is in development mode or production mode from my OSB proxy service?
    I m not able to find any doc on this??Please let me know how it can be done?
    Thanks

    There isnt any other way except for doing a Java Callout. In the callout method you can access the Domain/Server MBean for the information that you seek. Based on the callout result you can go ahead with the logic in your PS..
    Here is a sample Java Code to get the Server Log Level and ascertain whether the server is in Production Mode or not.
    package com.dell.mbean;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.util.Hashtable;
    import javax.management.MBeanServerConnection;
    import javax.management.MalformedObjectNameException;
    import javax.management.ObjectName;
    import javax.management.remote.JMXConnector;
    import javax.management.remote.JMXConnectorFactory;
    import javax.management.remote.JMXServerErrorException;
    import javax.management.remote.JMXServiceURL;
    import javax.naming.Context;
    public class MyConnection {
         private static MBeanServerConnection connection;
         private static JMXConnector connector;
         private static final ObjectName service;
         static {
              try {
              service = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");
              catch (MalformedObjectNameException e) {
              throw new AssertionError(e.getMessage());
         * Initialize connection to the Domain Runtime MBean Server.
         @SuppressWarnings("unchecked")
         public static void initConnection(String hostname, String portString,
         String username, String password) throws IOException,
         MalformedURLException {
         String protocol = "t3";
         Integer portInteger = Integer.valueOf(portString);
         int port = portInteger.intValue();
         String jndiroot = "/jndi/";
         String mserver = "weblogic.management.mbeanservers.domainruntime";
         JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port,
         jndiroot + mserver);
         Hashtable h = new Hashtable();
         h.put(Context.SECURITY_PRINCIPAL, username);
         h.put(Context.SECURITY_CREDENTIALS, password);
         h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");
         h.put("jmx.remote.x.request.waiting.timeout", new Long(10000));
         try {
         connector = JMXConnectorFactory.connect(serviceURL, h);
         connection = connector.getMBeanServerConnection();
         } catch(JMXServerErrorException jmxSE)
              jmxSE.printStackTrace();
         catch(Exception ex)
              ex.printStackTrace();
         public static String getLogSeverity(String hostName, String portName, String userName, String password) throws Exception {
              initConnection(hostName, portName, userName,password);
              connector.close();
              ObjectName domainConfig = (ObjectName) connection.getAttribute(service,
              "DomainConfiguration");
              ObjectName logMbean =(ObjectName) connection.getAttribute(domainConfig, "Log");
              String logFileFilter = (String) connection.getAttribute(logMbean, "LogFileSeverity");
              System.out.println("Log File Filter= "+ logFileFilter.toString());
              return logFileFilter;
         public static boolean isProductionModeEnabled(String hostName, String portName, String userName, String password) throws Exception {
              initConnection(hostName, portName, userName,password);
              connector.close();
              ObjectName domainConfig = (ObjectName) connection.getAttribute(service,
              "DomainConfiguration");
              boolean prodEnabled= (Boolean) connection.getAttribute(domainConfig, "ProductionModeEnabled");
              System.out.println("Is Production Mode Enabled=" +prodEnabled);
              return prodEnabled;
    Make sure you have wlclient.jar and wljmxclient.jar as your dependent libraries.

  • How to check if an SQL profile is being used or not?

    Hi,
    We have a couple of SQL profiles and outlines in the database. There has been a couple of code changes and it is now difficult to keep track if an SQL profile or an Outline is still being used? Is there any way to find that?
    Thanks in advance

    Find the entry corresponding to the SQL statement you are reviewing in V$SQL. Look at OUTLINE_CATEGORY and SQL_PROFILE columns. NULL indicates that no Outline/Profile was used.

  • How to check whether a SMTP server is supporting Authentication or not

    Hi All,
    We are using Java Mail API 1.3.1/1.3.2 to send the messages. some of the SMTP servers that we use are supporting authentication and some of them are not.
    As the SMTPTransport.supportsAuthentication() is not available only in Java mail API 1.4.1, we are identifying the SMTP server whether it is supporting authentication or not in the following way.
    Socket clientSocket = null;
    InetSocketAddress socketAddress = null;
    OutputStream outStream = null;
    InputStream inStream = null;
    InputStreamReader inReader = null;
    OutputStreamWriter outWritter = null;
    try
    clientSocket = new Socket();
    socketAddress = new InetSocketAddress(host, port);
    clientSocket.connect(socketAddress, timeout*1000); // convert timeout from second to miliseconds
    // 1: now try to execute the given command by passing that on Out-Socket
    outStream = clientSocket.getOutputStream();
    outWritter = new OutputStreamWriter(outStream);
    outWritter.write("ehlo localhost" +"\n");
    outWritter.flush();
    // 2:Read output of above command
    inStream = clientSocket.getInputStream();
    inReader = new InputStreamReader(inStream);
    // This array limit would be fine to get "AUTH" extension of smtp server.
    char[] arr = new char[16384];
    StringBuilder strBuilder = new StringBuilder();
    inReader.read(arr);
    for(int i=0; i< arr.length; i++)
    strBuilder.append(arr);
    System.out.println(METHOD_NAME + "SMTP server response for ehlo localhost command ->"+strBuilder.toString());
    // The output EHLO command comes like below :
    // ehlo localhost
    // 250-ap9058pc.us.oracle.com Hello ap614ses.us.oracle.com [130.35.33.43], pleased to meet you
    // 250-ENHANCEDSTATUSCODES
    // 250-PIPELINING
    // 250-8BITMIME
    // 250-SIZE
    // 250-DSN
    // 250-ETRN
    // 250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
    // Since for XATUH ( like internal IP),
    // we are not sure, so just checking for AUTH capability.
    supported = strBuilder.indexOf("250-AUTH") >=0? true : false;
    As shown in above code, we are issuing 'ehlo localhost' command to SMTP server, if the response i. 'strBuilder' contains '250-AUTH' then we are assuming that it is supporting authentication.
    But for one SMTP server the 'strBuilder' value is showing as '220 mail.durofelguera.com ESMTP Service (Lotus Domino Release 8.5.2) ready at Thu, 16 Feb 2012 13:57:20 +0100' only which is socket connection output but not 'ehlo localhost' command output.
    where as the telnet test output is showing correct only as below
    # telnet mail.durofelguera.com 25
    Trying 172.20.16.65...
    Connected to mail.durofelguera.com.
    Escape character is '^]'.
    220 mail.durofelguera.com ESMTP Service (Lotus Domino Release 8.5.2) ready
    at 0
    ehlo localhost
    250-mail.durofelguera.com Hello localhost ([172.20.15.209]), pleased to meet
    yu
    250-HELP
    250-AUTH LOGIN
    250-SIZE
    250 PIPELINING
    AUTH LOGIN
    The question is why the 'strBuilder' is not showing 'ehlo localhost' conad output where as the telnet test results are showing correctly, what is going wrong here?
    Is there any other way to check that whether SMTP server is supporting authentication or not?
    Edited by: sarojak on Feb 19, 2012 10:11 PM

    There are so many things wrong with your code, it's hard to know where to start...
    Basically, the problem is not as simple as you think it is.
    For example, some servers might not allow authentication until you've issued
    the STARTTLS command.
    These days, essentially all servers allow authentication. You're probably better
    off just assuming the server supports.

Maybe you are looking for

  • Changing dvd drive help

    I have a presario S7150 and want to change dvd/cd rom drive. New drive is S ATA old one is IDE, cant find where to plug the SATA cable into . Do I need an adapter or is there a place to plug in on the motherboard and if so where.

  • Greek (alfa) character in forms developer 10g

    Hi everyone, I'm trying to assign the first letter of the Greek alphabet to a text_item, but I don't know how to get it. I get no problem when trying to show ß using chr(223) or µ using chr(181) but no idea how to write the alfa char. By the way, reg

  • Convert from v.10 to v.9

    Hi, all. This topic isn't really a question, just to ask a favour. I created a LabView project when using LB version 10, then I downgraded to version 9, and I forgot to convert it. It's just a project file and several VIs. Could somebody using LB v.1

  • Why does Adobe Manager crash when I create to download programs from the creative cloud?

    I just signed on to Adobe Creative Cloud and trying to download apps to my desktop and Adobe Manager crashed everytime. I am running on OSX 10.9.4. Any suggestions?

  • Palm stopped working suddenly

    Palm Desktop 6.2 installed with Win 8 and Aceeca 64bit driver downloaded.   In trying to advance from one month to next on desktop prompt says Palm has stopped working, windows will close and determine solution.  Windows does not close program, no so