File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes A drop pf help might quench my thirst!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "A drop pf help might quench my thirst!!" Watch "A drop pf help might quench my thirst!!" New topic
Author

A drop pf help might quench my thirst!!

Saptarshi Chaudhuri
Greenhorn

Joined: Apr 12, 2009
Posts: 6
Hello everyone.I am new here and am also new to the world of Java.I am a second year student(computer science) and recently was alloted a RDMS project.Thats why I started learning Java.
The project that I am going to submit is about creating an HR Management Systems.I am using Netbeans 6.5 and successfully connected to Oracle(10g Xpress edition) through the following code:



Now what I need is to create other classes within the same package "humanresourcemanagement" and which actually contains the GUI and other internal Query executing programs. My question is how to create that?

I have tried the following:
Source Package->new->Java Class->"Insertion file" //it gets added to the default package
humanresourcemanagement->new->Java Class->"Insertion file" //it gets added along with the Main.Java file and imports humanresourcemanagement


Again since I have the connection variable in the "Main.Java" file, so how will I be able to use it in my new "Insertion" class??
Do I need to add the entire connection code in all the new "Insertion","deletion" etc classes??......

To sum it up in a few words,i want the connection part to be kept separately in the Main.Java class, and all the other GUI and query execution programs on other separate files and have them linked somehow??

Please I am new to JAVA(with background in C)..so what I am wanting here may not be the correct way to do the things,if that is the case then please advise me with better options

Finally just to add,I am really into making this project and thus is undergoing the painful transition from C to JAVA(and I am really excited about it too) and so am really working hard. So any kind of help will be highly appreciable from this end. Thank you

[edited to add code tags]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29261
    
140

Saptarshi,
Welcome to JavaRanch!

Have you learned about objects yet? You can create a database object the knows about the connection and does queries.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Saptarshi Chaudhuri
Greenhorn

Joined: Apr 12, 2009
Posts: 6
I know that. Actually using the oblects of Statement class I can execute queries.But the problem I am facing is the code for executing those queries has to be included in my Main.Java program(source code above,).But I want to write separate programs for query execution and get them included in my package"hrmanagementsystems".How will I be able to that??

I want to keep the connector program(the sourcr code above,which is also the Main.Java class of my package) separate from the GUI programs that I will make for my database.But the GUI programs will need the connector variable that i have defined in "Main.Java"..how will I be able to use that??

I am very sorry for not being able to actually explain my problem here...in C I would have simply done this:
#include "databaseconnector.h"
and then I could have used the connector vriable in my program here. But I dont know how to do it in Java.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29261
    
140

Saptarshi,
I'm trying to say that you wouldn't have a connector variable in your main class.

Suppose you had a class called MyQueryRunner. You could instantiate that class in your main class and call methods on it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A drop pf help might quench my thirst!!
 
Similar Threads
Help with this code!
need help regarding property file
String questions
Java SE6 client for EJB - Error in lookup
Display an array in a swing type box