Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9226373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:48:52+00:00 2026-06-18T04:48:52+00:00

I did this JDBC code for fetching some data from the database Oracle 10g

  • 0

I did this JDBC code for fetching some data from the database Oracle 10g using Play Framework 1.2.5:

Connection conn = DB.getConnection();
PreparedStatement  stmt = null;
System.out.println(conn);
try {
    stmt = conn.prepareStatement("select dept_id from emp where emp_id = 11");
    ResultSet rs = stmt.executeQuery();
    while (rs.next()) {
        System.out.println("Dept Id: " + rs.getInt("dept_id"));
    }
} catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

This approach is working but I am having a confusion:

If I comment the entire block of code and run the application then I can see the message in the console stating the connection is made to the DB. Hence :

1) Is the above block of code the right approach to fetch the data from Oracle DB or something better than this is present?

2) Is it like for the entire application lifetime, the connection with tht DB will persist?

I am a newbie in this, hence struggling 🙁

Please let me know hoe to proceed with this.

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:48:54+00:00Added an answer on June 18, 2026 at 4:48 am

    You need to read the play JPA documentation: http://www.playframework.org/documentation/1.2.5/jpa#finding

    Your queries should look like this:

    Post.find("byTitle", "My first post").fetch();
    Post.find("byTitleLike", "%hello%").fetch();
    Post.find("byAuthorIsNull").fetch();
    Post.find("byTitleLikeAndAuthor", "%hello%", connectedUser).fetch();
    

    And if you need to do a full query, you can add the JPA code in find:

    Post.find(
        "select p from Post p, Comment c " +
        "where c.post = p and c.subject like ?", "%hop%"
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to connect to the oracle DB using Play Framework 1.2.5. FOr this
I'm new to clojure. Have been playing with jdbc using hsqldb. Did this function
I am using Spring Roo 1.2 and changed my database connection from mysql to
i did this to get the result from parse.com curl -X GET \ -H
I'm refactoring some legacy code, and I keep running into this Object. I would
I am trying to send a blob data from oracle db to objective c
I suddenly noticed that Oracle JDBC driver that I was using With Oracle 11g
I did a small example program to insert data to a MySQL database table
I believe that oracle.jdbc.V8Compatible has been deprecated in Oracle 11 Is this because for
I am trying to get a connection to a SQLite database (using Eclipse on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.