Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

How to use JDBC to get access to a database in a java program?

The Java program is to be used as an executable and placed in a bat file to be a schedued process.  I do not know what type driver I should use. I'm thinking Type 3.  Is that the correct way? The Type 3 driver where it is a native protocol where all java driver converts JDBC calls into a native DBMS protocol. Since this conversion takes place on the server side , no installation is required on the client machine.  As a result will it be ok for me to acces this way. Can I get an example of connecting to a database using this approach.  
I get confused whether a Ssession object is to be used or not.  Also when I connect the server side, does that mean I can still use server-side java code in a program that is to be run as a batch job?  I will make the connection into a class, then I will access the
database tables in another java program.  
The code will be written in WebSphere.  But does that mean I can still do a batch job that will be scheduled with a scheduler or an AT command?
0
coolgem
Asked:
coolgem
  • 2
  • 2
1 Solution
 
schmidaCommented:
which database (mysql, ms sql, oracle, ...) do you want to connect to?
0
 
coolgemAuthor Commented:
oops oracle
0
 
schmidaCommented:
a type 3 driver is ok for your task. Here are samples for oracle how to connect:

http://home.clara.net/dwotton/dba/jdbc_test.htm

http://www.rgagnon.com/javadetails/java-0112.html

I think you do not necessarily need a session object. I don t quite understand what you exactly want to achieve. Do you want to write a java application which changes something in your db an which can be accessed from the clients? This java application shall be started from a scheduler? This would be no problem no matter which ide you use (Websphere would be ok).
0
 
coolgemAuthor Commented:
i use Websphere.
However, I have to write a java program as ascheduled process.  I have to access three databases for the purpose of sending JavaMail to up to 11000 users.  Most likely the number will be much smaller.  A person will look at their records(images) and place an x in a checkbox. The scheduled java program will run at a specified time and look to see if an individul's records(images) have changed since they approved their records.  If the records changed after approval, the individual receives a JavaMail stating their records have changed since they approved.  This will all hapeen within a 40 day window.
Thank you for your time and patience. Being relativly new to java  programming causes me confusion with respect to this project. Reason is:
I need to know how to connect to a database and how to access the database tables. I figured I should first learn how to connect, then acess some tables and prinln the data to see that process work first. Also I need to get the technicality out ot the way to run either preference 1 or 2 below
(Preference 1)
If I use WebSphere then what do I need to do to get the job running at aschedule time? And How do I get the job started to run the first time and continue to run? It seems that I would have to use a browser, if I schedule a process within webSphere.  (Preference 2)
Can I schedule a batch job that is run within webSphere? If so How?
I'd like to perhaps run an executable from a bat file that is scheduled to run before dawn from a schedular.  If so can I run a program bathwise that can connect thru WebSphere and also access the three databases. I do not understand if this can be done. I thought that if I use WebSphere sthedn I would have to use session objects or whatever. I don't see how I can uses session objects when I'm running a batch type program
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now