• Post Reply Bookmark Topic Watch Topic
  • New Topic

Executing SQL queries in JAVA using JDBC  RSS feed

 
alfredo phoenix
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I write the incorporate the following query in my java code? I have a SQL query to fix my issue but can someone help me execute this in Java using JDBC?

--create temporary table housing the correct end dates for the same employee having multiple 01/01/3000 end dates sorting by start date and partition by emp_id


--update ent_emp_policy with correct end dates for erroneous records


--drop temp table
 
Henry Wong
author
Sheriff
Posts: 23026
120
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Topic moved from the Wiki forum to the Java in General and JDBC forums. As this topic is not a Wiki, and hence, not in the right location.

Henry
 
salvin francis
Bartender
Posts: 1493
23
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that you have a couple of queries to be executed in java and they include a temporary table.
You need to follow the following steps in your code:
  • Initialize the JDBC driver
  • Establish a Connection
  • Execute your queries
  • Close the connection


  • A more detailed tutorial can be found at : https://docs.oracle.com/javase/tutorial/jdbc/basics/

    Let us know what you have done so far and then we can help you out.
     
    alfredo phoenix
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Can you please help me with the java code?
     
    Campbell Ritchie
    Sheriff
    Posts: 54034
    130
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Have you been through the tutorials link which Salvin gave you?
     
    fred rosenberger
    lowercase baba
    Bartender
    Posts: 12464
    43
    Chrome Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    alfredo phoenix wrote:Can you please help me with the java code?

    If by "help" you mean "provide it all to me", the answer is no.

    If you mean "I know how to do a little/some/most of it but I'm stuck in a few places", then absolutely. Post what code you have, tell us what it's doing, what it's not doing, what you think it should be doing, error messages, etc.
     
    alfredo phoenix
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ok, I didn't mean to ask you all to provide me the code.. I have written the code but I feel my prepared statement is incorrect. I just need help in proof reading the code and suggest the corrections. Following is my code. Basically in the UI, the column end_date is showing the default date of 01-JAN-3000. If an employee is turning from part time to full time, his end date of part time should show up rather than the default date. In case the database doesn't has his end date, then the start date of his full time - 1 should be his end date for the part time while the end date for full time should be the default date.

    The query does the following:
    Retrieves all emp_ids which are having multiple end dates as 01-JAN-3000,
    Using Oracle Window function to retrieve the start date for next row in partition for particular emp id and subtract 1 day from next start date to correct end date. Update ent_emp_policy using Merge to correct ENT_EMPOL_END_DATE for that particular ENTEMPOL_ID.

     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!