facebook

Using preconfigured database connection in java code

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #309015 Reply

    Riadh
    Member

    hi,
    my question is about using the preconfigured connection ( with database browser )
    in my java code , how i mention the connection and use the JDBC objects to interrogate my database

    please give me an example with my eclipse IDE( i am novice in using Myeclipse IDE)

    #309037 Reply

    support-joy
    Member

    riadhben,

    I would recommend you go through MyEclipse tutorials and white papers here – http://www.myeclipseide.com/module-htmlpages-display-pid-7.html

    Here is the link to MyEclipse Database tutorials – http://www.myeclipseide.com/documentation/quickstarts/dbtools/

    #309048 Reply

    Riadh
    Member

    Thank you for your answer,

    before working with persistance ( hibernate or JPA), i like to test a simple Java application with JDBC ( with all steps) ,
    the problem is how i can use an preconfigured object ( in this example the database connection) in Java code
    for example when i create a connection class that declare the driver Manager and create a connection, statement ……..
    i defined the connection with the database explorer with name”Oracle”, how i can mention the connection in code.

    the tutorial explain how to modify the structure of data base and querying it with SQL files , i like to know how i can interrogate the database with SQL code integrated in java
    if you know a better practice to manage the connection with database , you can explain it.

    thank you for help.

    #309052 Reply

    riadhben,
    I would recommend you to go through the following links on how to use JDBC to connect and query database –
    1. http://www.jdbc-tutorial.com/
    2. http://www.kitebird.com/articles/jdbc.html

    Hope that helps.

    #309055 Reply

    Riadh
    Member

    thank you “shalini”,
    i know all steps of connection with JDBC , but my question is about the utility of using database browser,
    i declared my database with database browser (mention the JDBC driver, the name of database, number of the port…) ,

    after how i can use thes objects , it can be considered as a global variable?
    for example , i declare a connection with name “oracle”

    in java code , i shoud declare a new connection object : Connection con = DriverManager.getconnection(“”);

    or i use the connection declared with dtabasebrowser? how?

    #309071 Reply

    riadhben,
    The Driver details given in the DB browser cannot be used directly in the JAVA code. They help you to manipulate the database details directly from the IDE. At the same time, when configuring persistence details of projects using JPA/Hibernate, the connection and the tables can be used directly from the DB browser.
    Please go through the following links –
    1. DB tools – http://www.myeclipseide.com/documentation/quickstarts/db_overview/
    2. Using DB browser for Hibernate Rev Engg – http://www.myeclipseide.com/documentation/quickstarts/hibernate/#5-4
    Let me know if that helps.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Using preconfigured database connection in java code

You must be logged in to post in the forum log in