About Connection, ResultSet, Statement interfaces....

hi ,
Connection, ResultSet, Statement etc.. all are the interfaces. But when i am writing the codes like,
Statement stmt= con.createStatement();
ResultSet rs= stmt.excuteQuery("select * from student_mst");
where con is the instance of Connection interface.
Therefore my question is that since all those(Connection,ResultSet,Statement) are interfaces then how the methods createStatement(),excuteQuery(String sql) are being executed where as those methods are only the declarations in those interfaces,nothing else.

ok.......
So can u tell me in this case, actualy which class is
implenting the Statement interface such that
"executeQuery(String)" is working properly.....??????Hello,
First you need to understand interface and its working.. I will write one example code for u and I think this may hel how Connection, Statement and ResultSet work
This is out main Class
public class Main {
     public static void main(String[] args) {
          Connection con = DriverManager.getConnection();
          Statement stmt = con.createStatement();
          ResultSet rs = stmt.executeQuery("My Query");
          rs.getString();
}Connection.java
public interface Connection {
     public Statement createStatement();
}Statement.java
public interface Statement {
     ResultSet executeQuery(String sql);
}ResultSet.java
public interface ResultSet {
     public String getString();
}DriverManager.java
public class DriverManager {
     public static Connection getConnection()     {
          System.out.println("Calling getConnection()...");
          return new ConnectionImpl();
}Following are the implementstions of the interfaces
ConnectionImpl.java
public class ConnectionImpl implements Connection {
     public Statement createStatement() {
          System.out.println("Calling createStatement()...");
          return new StatementImpl();
}StatementImpl.java
public class StatementImpl implements Statement{
     public ResultSet executeQuery(String sql) {
          System.out.println("Calling executeQuery()...");
          return new ResultSetImpl();
}ResultSetImpl.java
public class ResultSetImpl implements ResultSet{
     public String getString() {
          System.out.println("Calling getString()...");
          return "My String";
}And the Output is
Calling getConnection()...
Calling createStatement()...
Calling executeQuery()...
Calling getString()...
I suppose now you can understand how the Connection, Statement and ResultSet interfaces work

Similar Messages

  • Connection/ResultSets/Prepared Statement opening and closing

    Hi all another question that was sparked by a thread that I recently read. I believe it was duffmo who got the code from jverd. The code I am referring to is to have an open and close connection specified in a Utility or Database class. I wanted to know if there was any issues with having methods that open and close connections/result sets/ preparedStatements. Currently I am putting the finally blocks inside each of my methods. There is obvious benefits to putting the methods in a class on their own (namely code re-use) but I wanted to know if there are any dangers. (This may seem like a dumb question, but I've found from experience it's the things that you don't know that will cost you loads of time).
    thanks again.

    Hi all another question that was sparked by athread
    that I recently read. I believe it was duffmo who
    got the code from jverd. Generally speaking it's fine.
    But as always you may have some long term design
    issues to think about. If you build a simple
    framework that consists of one class and that does
    all that your program does then great.
    Once you start add more complexity though you'll want
    to be careful that you aren't reinventing the Spring
    wheel or even ending up implementing your own
    connection pool. Both of which, judging from posts
    here seem to happen from time to time.
    So I guess all in all, yes it's much better than
    scattering the code all about but depending on what
    you are going to be doing with it you may want to
    look at the various ORM frameworks to see if they are
    really the direction you should be going in.Thanks for the information cotton. I just wanted to make certain that it was a sensible thing to do. When I had first asked about connections I was told they should be opened an closed in the same spot, unfortunately I took that explanation a little too much to heart, and started opening and closing every connection resultset and prepared statement in each of the DAO classes that I was using.
    Guess it's going to be a bit of work to refactor, but worth it for the cleaner code that will result.

  • How to find out resultset,statements and connections are not closed

    Hello,
    In Jdeveloper 10.1.2 how can I find out that in my code,
    I have resultset,statements and connections are not being closed.
    Any help is highly appreciable.
    Thanks

    Hello Vijay,
    On MSSQL truncation of transaction log does not shrink the size of the transaction log. It simply removes the content within the transaction log and writes it to the backup.
    Meaning the free percentage within the transaction log will increase.
    If you want to Resize the transaction log size, you need to do something else.
    The shrinking procedure is given here:
    http://support.microsoft.com/kb/907511
    Regards,
    Siddhesh

  • Where did we find connection statement interfaces?

    where did we find connection ,statement interfaces when we are working with type 4 driver?

    where did we find connection ,statement interfaces
    when we are working with type 4 driver?The interfaces are always present in rt.jar. :)

  • ACE Total Connections Failed stats

    I have been monitoring connection stats on an ACE Module context (show stats connection).
    During recent load testing I observer that about 1/3 of all connections were failing and some timing out.
    How can I find out more details about the connections that are failing and timing out?
    ie which specific connection are failing, what type of failures increment this counter, etc
    Cheers,
    Karl
    # sh stats conn
    +------------------------------------------+
    +------- Connection statistics ------------+
    +------------------------------------------+
    Total Connections Created : 5725
    Total Connections Current : 2382
    Total Connections Destroyed: 3590
    Total Connections Timed-out: 11
    Total Connections Failed : 2112

    Hi Kim,
    Thanks for responding.
    A load test was run earlier today. I cleared the counters and collected some stats (see below).
    I also had a look at various other stats for drops.
    As far as I could see all relevant, rservers, serverfarms and service-policies were:
    in service BUT
    drop stats were not incrementing at anywhere near the same rate as the Total Connections Failed stat.
    Another load test is scheduled for tomorrow.
    Any thoughts on what to check next?
    labcorelb/DZ1ENV# sh stats conn
    +------------------------------------------+
    +------- Connection statistics ------------+
    +------------------------------------------+
    Total Connections Created  : 131698
    Total Connections Current  : 3660
    Total Connections Destroyed: 67558
    Total Connections Timed-out: 70
    Total Connections Failed   : 64090
    +------------------------------------------+
    +-------------- HTTP statistics -----------+
    +------------------------------------------+
    LB parse result msgs sent : 91904      , TCP data msgs sent       : 187614   
    Inspect parse result msgs : 0          , SSL data msgs sent       : 0        
                          sent
    TCP fin msgs sent         : 75         , TCP rst msgs sent:       : 3        
    Bounced fin msgs sent     : 0          , Bounced rst msgs sent:   : 0        
    SSL fin msgs sent         : 0          , SSL rst msgs sent:       : 0        
    Drain msgs sent           : 31831      , Particles read           : 397303   
    Reuse msgs sent           : 0          , HTTP requests            : 64390    
    Reproxied requests        : 58314      , Headers removed          : 0        
    Headers inserted          : 0          , HTTP redirects           : 0        
    HTTP chunks               : 741        , Pipelined requests       : 0        
    HTTP unproxy conns        : 64360      , Pipeline flushes         : 0        
    Whitespace appends        : 0          , Second pass parsing      : 0        
    Response entries recycled : 0          , Analysis errors          : 0        
    Header insert errors      : 0          , Max parselen errors      : 0        
    Static parse errors       : 0          , Resource errors          : 0        
    Invalid path errors       : 0          , Bad HTTP version errors  : 0        
    Headers rewritten         : 0          , Header rewrite errors    : 0        
    SSL headers inserted      : 0          , SSL header insert errors : 0        
    SSL spoof headers deleted : 0        
    Unproxy msgs sent         : 64362    
    +------------------------------------------+
    +--------- HTTP Inspect statistics --------+
    +------------------------------------------+
    Total request/response   : 0
    Total allow decisions    : 0
    Total drop decisions     : 0
    Total logging decisions  : 0
    +------------------------------------------+
    +------- Loadbalance statistics -----------+
    +------------------------------------------+
    Total version mismatch              : 0
    Total Layer4 decisions              : 142
    Total Layer4 rejections             : 0
    Total Layer7 decisions              : 64401
    Total Layer7 rejections             : 0
    Total Layer4 LB policy misses       : 0
    Total Layer7 LB policy misses       : 0
    Total times rserver was unavailable : 0
    Total ACL denied                    : 0
    Total IDMap Lookup Failures         : 0
    +------------------------------------------+
    +----------- Sticky statistics ------------+
    +------------------------------------------+
    Total sticky entries reused    : 0
    prior to expiry
    Total active sticky entries    : 0
    Total active reverse sticky    : 0
    entries
    Total active sticky conns      : 0
    Total static sticky entries    : 0
    +-----------------------------------------------------+
    +---------------- KAL-AP(UDP) statistics -------------+
    +-----------------------------------------------------+
    Total bytes received                         : 0
    Total bytes sent                             : 0
    Total requests received                      : 0
    Total responses sent                         : 0
    Total requests successfully received         : 0
    Total queries successfully received          : 0
    Total responses successfully sent            : 0
    Total secure requests received               : 0
    Total secure responses sent                  : 0
    Total requests with errors                   : 0
    Total requests with parse errors             : 0
    Total requests dropped due to queue overflow : 0
    Total response transfer errors               : 0
    labcorelb/DZ1ENV#sh service-policy Vip_POLICY summary
    service-policy: Vip_POLICY
    Class                            VIP       Prot  Port        VLAN          State    Curr Conns   Hit Count  Conns Drop
    xxxx34_HTTP_CLASS                xxxx.34   tcp   eq 80       ALL           IN-SRVC           0           0          0
    WCMST-WWW_HTTP_CLASS             xxxx.50   tcp   eq 80       ALL           IN-SRVC           7          48          0
    WCMST-FORUM_HTTP_CLASS           xxxx.111  tcp   eq 80       ALL           IN-SRVC           8         577          0
    WCMST-SEARCH_HTTP_CLASS          xxxx.51   tcp   eq 80       ALL           IN-SRVC           0         174          0
    WCMST-ENGINEADM_HTTP_CLASS       xxxx.112  tcp   eq 80       ALL           IN-SRVC           0           0          0
    INTERNET-WWW_HTTP_CLASS          xxxx.110  tcp   eq 80       ALL           IN-SRVC        1794       33919         18

  • Replacement for Finder's "Connect to Server" interface?

    The Finder -> Go -> Connect to Server interface is a bit minimal, to put it mildly.
    Ideally, I'd like to be able to:
    • Rename the connections ("smb://192.168.1.32" isn't very helpful)
    • Organize them in folders
    • Sort by name, connection type, etc.
    • Specify whether or not to save user/pwd in the Keychain
    Anyone know of any third-party connection-manager utilities?

    That's what I was thinking. I have read numerous "how-to's" about this, and all of them say that this is possible, but I think what I am really reading is "How to copy files between computers" and not "How to use a PC as a server."
    Thanks again!

  • Connect firewire audio interface and external monitor

    I have just bought my MacBook Pro 13 and I will mainly use it for audio recording . I have connect my audio interface through the firewire port. I need to connect an external monitor . The only available ports are thunderbolt and USB . Can I connect a monitor with these available ports ?

    Hi charisio,
    Thanks for visiting Apple Support Communities.
    If you would like to connect an external display to your MacBook Pro, you can use the Thunderbolt port. See these articles for some good information about Thunderbolt:
    Thunderbolt ports and displays: Frequently asked questions (FAQ)
    http://support.apple.com/kb/ht5219
    OS X Mountain Lion: About Thunderbolt
    http://support.apple.com/kb/PH11407
    All the best,
    Jeremy

  • Swtichs lost connection in trunk interface but still turn on

    Dear Friends,
    Since a week ago i have problems withs 4 or 5 access switchs that randomly lost the connection in trunk interface. The led in trunk interface turns off and i have to go to the site and turn off manually the switchs an then turn on to stablish again the connection. Before to turn off the switchs the logs shows:
    Jan 11 09:23:55.155: %SW_MATM-4-MACFLAP_NOTIF: Host fc99.471f.23bf in vlan 174 i
    s flapping between port Gi1/0/4 and port Gi1/0/11
    Jan 11 09:23:55.255: %SW_MATM-4-MACFLAP_NOTIF: Host e490.699f.86fe in vlan 117 i
    s flapping between port Gi1/0/4 and port Gi1/0/11
    Jan 11 09:23:55.591: %SW_MATM-4-MACFLAP_NOTIF: Host e41f.1377.3d65 in vlan 413 i
    s flapping between port Gi1/0/4 and port Gi1/0/11
    Jan 11 09:23:55.625: %SW_MATM-4-MACFLAP_NOTIF: Host f0f7.55b6.3f68 in vlan 413 i
    s flapping between port Gi1/0/4 and port Gi1/0/11
    Jan 11 09:23:55.759: %SW_MATM-4-MACFLAP_NOTIF: Host 0040.8cf5.5eb0 in vlan 113 i
    s flapping between port Gi1/0/4 and port Gi1/0/11
    Jan 11 09:23:56.589: %SW_MATM-4-MACFLAP_NOTIF: Host 0016.6c78.c1f4 in vlan 170 i
    s flapping between port Gi1/0/4 and port Gi1/0/11
    Jan 11 09:23:56.589: %SW_MATM-4-MACFLAP_NOTIF: Host 0016.6c76.a951 in vlan 170 i
    s flapping between port Gi1/0/4 and port Gi1/0/11
    Jan 11 09:23:57.806: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthe
    rnet1/0/1, changed state to down
    This is common in all the switches that lost connection. The MACs are different in all switches so i cannot know if there are an specific host that causes the problem. Please your support.

    Hi Reza,
    Both ports are trunk.
    interface GigabitEthernet1/0/4
     switchport trunk encapsulation dot1q
     switchport mode trunk
    interface GigabitEthernet1/0/11
     switchport trunk encapsulation dot1q
     switchport mode trunk
    Any idea?

  • Please Help !  Exception in closing resultset,statement.

    In an application developed on , i am closing the resultsets and statements in finally block as
    finally {
         if (resultset != null) resultset .close();
         if (statement != null) statement.close();
    the above block does not take care of exceptions that might arise while closing resultset/statement. Please help with this:
    what the conditions exceptions may arise in closing resultset/statements.
    when does the garbage collector free such resources and what are the implications of not catching exception while closing - can this cause database handle leaks.
    Please help!

    I don't know what exceptions might occur, but since the close() method can throw SQLException, your program has to catch it. Maybe if you close twice, the second time will throw an exception? Anyway, it doesn't really matter, you still have to write a try-catch around it. What you do there is up to you -- you could ignore it (which is what I do) or you could end the program with a message.
    When does the garbage collector free those resources? The garbage collector only frees memory. Nothing else. And the garbage collector will free a ResultSet object only when there are no references to it anywhere in your program. That doesn't mean just in code that you wrote, but anywhere in code that's running in your program. For example, the Statement object that produced the ResultSet might hold a reference to it. However, the API documentation for ResultSet does say that when the garbage collector does free a ResultSet object, it will automatically close it.
    However, the best practice is to close ResultSet and Statement objects when you are finished with them, and not rely on garbage collection to clean up after you.

  • The video player is in the connection error state.

    Flash cS 5.5 / Win 7. Inserting video into movieclip both with 'import video' wizard and via component. FLV that plays fine on a number of different servers. On opening (after gathering metadata) the message 'The video player is in the connection error state. It enters this state when a video stream attempted to load but was unsuccessful. There are two possible reasons for the error: no connection to the server or the stream was not found.' Firstly I am treating this as a progressive download, not streaming. Second this plays fine locally, it's only when I upload to a server it fails. The FLV is in a folder directly below the SWF. Result is same with FLV in same location as SWF. MIME type set to vide/x-flv although I've also set it to applicaiton/octet-stream.
    This is a very basic requirement to call the video directly from Flash, the default parameters of the component are adequate and work locally. However the video does not play. Is it fair to assume this functionality simply does not work correctly within Flash CS5.5? I'm unclear as to what >less< I could be doing with this file.

    You can place the Flash and any Flash assets in any folder location that you want.... provided that you understand how Flash assets (like .flv files) are "Pathed" or located by the .swf that is calling them. The underlying principle is that the Flash assets need to be pathed relative to the Web page that the .swf is located on, NOT the actual, physical location of the .swf.
    For review:
    Pathing issues
    Almost always when it works on the local machine and not the server, it's a pathing problem.
    You can put your Flash related files in whatever folders you want, they do NOT have to be in the root, they do NOT all have to be in the same folder. But if you have a problem and if sticking them all in the root folder works, then you know that the issue was a pathing problem.
    Just remember that paths used in the .swf become relative to the Web page on which the .swf is placed, NOT it’s physical location.  So for example, if your .swf is in the flash/data folder and you use that .swf on a Web page in the root folder, you are in effect, removing that .swf from flash/data and putting it in root. So if the .swf is loading any related files (xml, images, video, etc), the path used inside the .swf to load the .xml file has to be relative to it's new location in root and then back down into flash/data. This is true even though when testing the .swf by itself, it can be inside flash/data and work just fine, since relative to it's location, the path is just fine, they are in the same folder. But if that same path is used when the .swf is placed on a page two folder levels up, the relative path has changed, the old "same folder" path will not work.
    In fact if you are placing the .swf on a web page in a different folder than the .swf is stored in, and that .swf calls external assets, then direct clicking and opening of the .swf in it’s folder should NOT work! That’s because the paths to the external assets should be relative to the Web page and not the physical location of the .swf.
    So just be sure that you use addresses relative to the final Web page locations (not physical file locations) and you can put the Flash related files in what ever folders you want.
    Best wishes,
    Eye for Video
    www.cidigitalmedia.com
    So you can place the .flv wherever you want, but you can't just go and move the .flv without also correcting the path to the .flv inside the .swf.
    So be sure that you have the .flv in the correct subfolder before you do any insert of the Flash player.
    Also I'm not a great fan of requiring my viewers use the latest and greatest (and most bug filled version) of any pluggin or software for that matter.
    <param name="swfversion" value="11.0.0.0" />
    I refer NOT to upgrade to ver 11 so will not be seeing your Flash anytime soon. If you want to appeal to a large audience, change that to version 10.
    Best wishes,
    Adninjastrator

  • I keep on getting an error when logging onto my whatapp telling me about connecting to itunes, Ive now backed up and restored but im still getting the same message connect ot itunes for push messages

    I keep on getting an error when logging onto my whatapp telling me about connecting to itunes, Ive now backed up and restored but im still getting the same message connect ot itunes for push messages

    Hello there, Minig1501.
    The following Knowledge Base article has some information on the message you're receiving:
    Unable to use Apple Push Notification service (APNs)
    http://support.apple.com/kb/TS4264
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro D.

  • Unable to connect SQL State=S1000 [Oracle][ODBC][Ora]ORA-12170:

    Hi all,
    I have an Windows XP OS with SP3.
    I have installed the Oracle 11g server.
    On trying to connect to the ODBC connection, i get the following error message:
    Unable to connect SQL State=S1000 [Oracle][ODBC][Ora]ORA-12170: TNS: Connect timeout occured
    On trying the tnsping,
    TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 09-OCT-2
    011 13:11:05
    Copyright (c) 1997, 2007, Oracle. All rights reserved.
    Used parameter files:
    E:\app\Gautam\product\11.1.0\db_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.
    5.207)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl))
    TNS-12535: TNS:operation timed out
    On trying to connect with SQL Developer, i get the following error:
    Status: Failure - Test failed: Io Exception: The Network Adapter could not establish the connection
    However i am able to connect to the same using SQL Plus
    Another issue that occurs is that the Oracle Enterprise Manager shows the following error after a while:
    Agent Connection to Instance
    Status Failed
    Details ORA-12505: TNS:listener does not currently know of SID given in connect descriptor (DBD ERROR: OCIServerAttach)
    The following services are all up during this point of time:
    OracleDBConsoleorcl
    OracleOraDb11g_home1TNSListener
    OracleServiceORCL
    Any help in this regard will be very useful as this is hindering the progress of my work.
    Thanks in advance for the help.
    - Gautam

    841683 wrote:
    Hi,
    I did try and delete my listener.ora and then create a new one..
    That did not solve my issue..
    What are the steps for configuring the listener again.
    Thanks for the response..
    - Gautamno listener.ora file is required.
    just do as below
    lsnrctl start

  • 2 questions about connection to hyper-v in windows 8

    hi,
    I can connect to my virtual machine from hyper-v manager  ,but when I try the other option
    --- connect with hyper-v virtual machine(option)  I see  on the log on wizard telling me that I don't have  the right to run this job.  take contact with the autorazition policy administrator.
    1---my question is here ,   is connect with hyper-v virtual machine  option   is  specially purposed to connect with  virtual server or it has some onother function!   because I opened the autorazation
    policy on my windows 8 to see if I can edit some policies but I didn't see any function to creat one only it is asking for archieve.
    2--connction trough remote desktop to VM is only purposed from ouside or you can use it  to connect to VM internally too? very short answers wil be enough.
    thanks
    johan
    h.david

    thanks
    ,but wat about connect to hyper-v  virtual machine option in start menu(which is one of  hyper-v manage  programa's option  and  the second is shyper-v manager), why I can not connect through this option
     it gives  me Always an error with  that I don't have the right to run this  conect option through its log on  window and I have to contact my system administrator of autorization policy?
    is this option (connect) outside the hyper-v manager is purposed for the server or I have to change some policies on my computer to can log on to virtual machine from ouside the hyper-v manager with this second option
    johan
    h.david

  • I downloaded what's app and snap chat and it keeps coming up about connect to I tunes to turn on push notifications. I'm connected and turned them on but it still says I haven't when I have opened the app. Any ideas how to solve it?

    I downloaded what's app and snap chat and it keeps coming up about connect to I tunes to turn on push notifications. I'm connected and turned them on but it still says I haven't when I have opened the app. Any ideas how to solve it?

    Hey did anyone get back to you on what you can do? I'm having the same problem, it's bugging me! Lol

  • Problem in addBatch method in java.sql.Statement Interface

    Hi
    I am facing a problem java.lang.UnsupportedOperationException when using addbatch() method of java.sql.Statement Interface.
    Please suggest solutions.
    Thanks
    nsgindia

    Your JDBC driver doesn't support batch operation, try another driver(not all databases support batch'es eg MySQL)

Maybe you are looking for