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

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

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

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

    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'.

  • 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

    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);
    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).

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

    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 :
    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.

    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).setArray(2, pTable);
    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.

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

    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.
    <!--- Create an instance of the POIUtility.cfc. --->
        <cfset objPOI = CreateObject(
    <!--- 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
                             headerFlag = false
                        END IF
                   <!--- Read Excel File --->
                <cfset objSheet = objPOI.ReadExcel(FilePath =, HasHeaderRow = #variables.headerFlag#, SheetIndex = 0) />
    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>
                        Test 1st Row: #trim(replacenocase(listgetat(variables.i,1,","),'"',"","All"))#
    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?

    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.
    G. Lakshmipathi

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

    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,

    Hi Avraham ,
    To check whether the string is in upper case or not use CA keyward.
    To check  try the following code  ---
    W_ABCDE(26) TYPE C VALUE 'abcdefghijklmnopqrstuvwxyz'.
    w_string = 'abcd'.
    MESSAGE 'It is a uppercase string' TYPE 'S'.
    Try this link  this will definitely help you -

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

    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
    "ProductName"="NI-DAQmx MAX Configuration Support 9.3.5"
    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
    Go to Solution.
    Check Remote Registry ‏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...
    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

    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,

    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?

    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.

    check this link, it queries the properties of your system:

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

    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?

    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.
    import java.util.Hashtable;
    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,");
              catch (MalformedObjectNameException e) {
              throw new AssertionError(e.getMessage());
         * Initialize connection to the Domain Runtime MBean Server.
         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 = "";
         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("jmx.remote.x.request.waiting.timeout", new Long(10000));
         try {
         connector = JMXConnectorFactory.connect(serviceURL, h);
         connection = connector.getMBeanServerConnection();
         } catch(JMXServerErrorException jmxSE)
         catch(Exception ex)
         public static String getLogSeverity(String hostName, String portName, String userName, String password) throws Exception {
              initConnection(hostName, portName, userName,password);
              ObjectName domainConfig = (ObjectName) connection.getAttribute(service,
              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);
              ObjectName domainConfig = (ObjectName) connection.getAttribute(service,
              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?

    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;
    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");
    // 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();;
    for(int i=0; i< arr.length; i++)
    System.out.println(METHOD_NAME + "SMTP server response for ehlo localhost command ->"+strBuilder.toString());
    // The output EHLO command comes like below :
    // ehlo localhost
    // Hello [], pleased to meet you
    // 250-PIPELINING
    // 250-8BITMIME
    // 250-SIZE
    // 250-DSN
    // 250-ETRN
    // 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 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 25
    Connected to
    Escape character is '^]'.
    220 ESMTP Service (Lotus Domino Release 8.5.2) ready
    at 0
    ehlo localhost Hello localhost ([]), pleased to meet
    250-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

  • ITunes Match for the iMac - Music Files on an iPod?

    I subscribe to iTunes Match and have an iPod Classic 160GB. Is it possible to use iTunes Match for my entire music library on my iMac & iPhone BUT put the actual song files on my iPod Classic? The problem is my music library is large, won't fit on my

  • [Solved] Can't hear Skype and Web Browser at the same time?

    Hello. I am running Arch with Gnome and PulseAudio. I'm having a strange problem with audio. Whenever I have Skype open as well as a browser (Chromium) I can only hear one of the applications. (This happens in other applications as well.) For example

  • Class will only run with full package path - why?

    Hi, I've recently used Ant to package up a jar file with a simple gui application. Though I believe I've done everything right in terms of packaging I find that when I copy jar file to another computer not only do I need to unjar it I also need to us

  • Own tag in code templates of the abap editor

    Hi, i think you all know the code hints and that you can define own code templates in the abap editor (at the options screen). As an information I dont mean the code patterns. So does somebody know how to define own tags for these code templates? Or

  • How do you rebuild control files?

    I would appreciate any help if this is at all possible. I only work in the Oracle dba area when I have to, and then only as a consequence of other IT work looking after ERP systems. Background: I built an Oracle db as a demo environment some time bac