Solved

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

Posted on 2004-08-11
4
325 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.

832 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