Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-11
4
Medium Priority
?
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Make the most of your online learning experience.
Progress
Introduction to Processes

670 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