Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A drop pf help might quench my thirst!!

 
Saptarshi Chaudhuri
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saptarshi,
Welcome to JavaRanch!

Have you learned about objects yet? You can create a database object the knows about the connection and does queries.
 
Saptarshi Chaudhuri
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic