How to connect to database????/

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghu4uon
    New Member
    • Apr 2008
    • 4

    How to connect to database????/

    hi

    Can anyone give source code for connecting oracle 8 database to my java project????? i'm using jdk1.5, tomcat web server, oracle 8..... i have created the tables but i dont know how to connect?????


    plz help me reagrding this!!!!!!


    Regards


    Raghu N
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Please find the details here .

    Comment

    • raghu4uon
      New Member
      • Apr 2008
      • 4

      #3
      can you please tell me what does this line do????


      Code:
      Class.forName("oracle.jdbc.driver.OracleDriver");
               con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:lab2com38","scott","tiger");
      Regards

      Raghu.

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        That establishes the connects to the oracle server with username and password.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by raghu4uon
          can you please tell me what does this line do????


          Code:
          Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:lab2com38","scott","tiger");
          Regards

          Raghu.
          The Class.forName loads a class. In this case it loads the database driver for oracle (See the API specs for the Class class for more details).
          The second line, like Debas said, establishes a connection with database using the previously loaded driver and the provided connection parameters.

          Comment

          Working...