Results 1 to 2 of 2
  1. #1
    Harshit is offline Member
    Join Date
    Apr 2014
    Posts
    1
    Rep Power
    0

    Default implement interface

    I am creating an application in core java where i am using database. I need to create a database configuration file & include it all other files. So, how can i do that ?

    Java Code:
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:MYDSN","system","tiger");
    I cannot do this in an interface since only abstract methods exist there. I tried to create an another class file to extend it but my program is already extending other class i.e. javax.swing.JFrame

    How can i implement this ? just by creating the object of that class in main method ?

    Thanks

  2. #2
    jashburn is offline Senior Member
    Join Date
    Feb 2014
    Posts
    219
    Rep Power
    1

    Default Re: implement interface

    I'm not sure if I completely understand your question, but assuming you're trying to use the above 2 lines of code in an interface, then you're right that you cannot put them into the interface. They are to be placed into a concrete class. The concrete class does not need to extend anything to be able to use the above code. They only need to go into a method. See MySQL and Java JDBC - Tutorial. (Note the import statements to import the relevant classes.)

Similar Threads

  1. Implement Comparable interface
    By JojoDiaz in forum New To Java
    Replies: 3
    Last Post: 11-07-2011, 08:10 AM
  2. Replies: 25
    Last Post: 03-30-2011, 11:25 AM
  3. how to implement interface
    By makpandian in forum New To Java
    Replies: 1
    Last Post: 12-09-2008, 03:39 PM
  4. Can generic types implement an interface?
    By jdgallag in forum New To Java
    Replies: 3
    Last Post: 10-30-2008, 05:07 AM
  5. How to implement the Icon interface in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-24-2008, 12:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •