Solved

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

Posted on 2004-08-11
4
322 Views
Last Modified: 2010-04-17
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
Comment
Question by:coolgem
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:schmida
ID: 11776629
which database (mysql, ms sql, oracle, ...) do you want to connect to?
0
 

Author Comment

by:coolgem
ID: 11776766
oops oracle
0
 
LVL 1

Accepted Solution

by:
schmida earned 500 total points
ID: 11777263
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
 

Author Comment

by:coolgem
ID: 11777735
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now