Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,328 members, 7,808,103 topics. Date: Thursday, 25 April 2024 at 07:17 AM

Helo House,how Can I Bundle A Database File Into My Desktop Applicatn - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Helo House,how Can I Bundle A Database File Into My Desktop Applicatn (1393 Views)

Retrieving/selecting A Particular Number Of Random Rows From A Database Table / Steps To Upload A File Into A Website. Urgnet Pls! / Connecting To A Database Using Visual Basic (2) (3) (4)

(1) (Reply) (Go Down)

Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 8:10am On Jul 12, 2011
Good day,house,iam developn a desktop app for submitting registrant details and updating their details when necessary, the database file will be used for capturing other details such as images. I donot know if the XML implementation can handle d issue. A sample code will be highly appreciated. Thanx
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by megaplaza(m): 2:40pm On Jul 12, 2011
it depends on the language you are using but what you need is an embedded database system. If you are using java you can use sqlite, H2, or java derby database. I recommend H2, easy to learn and use.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by skydancer: 3:48pm On Jul 12, 2011
Eh, like megaplaza said, you should throw more light on your issue. XML can effectively store details, and if you're going to store pictures, you might want to use binary formatting to store as files, or just store the pictures in a folder.

Here's what the algorithm should look like:
Registration
Get registrant's details.
Verify details
Store details using XML or database

Verification
Enter name to update
Enter new details
Store updated details

Have you tried any code so far? What language do you want to use? Just get started and I'll see where I can come in. You can always holla here, https://www.nairaland.com/nigeria/topic-711271.0.html
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 7:36pm On Jul 12, 2011
@megaplaza n skydancer,thanx alot,actually,i'm using java,but ryt now am usn my phone to code,i'll be online in few days time then i'll copy the codes n mail it to you.
Pls can i have ur email address.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 7:39pm On Jul 12, 2011
@megaplaza n skydancer,thanx alot,actually,i'm using java,but ryt now am usn my phone to code,i'll be online in few days time then i'll copy the codes n mail it to you.
Pls can i have ur email address.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by megaplaza(m): 8:54pm On Jul 12, 2011
why not post the code here. Since i ddropped my mail here i started getting scam mails.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by skydancer: 2:11am On Jul 13, 2011
just copy the codes and paste it here so others can learn from your experience too cheesy
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by SayoMarvel(m): 10:28am On Jul 13, 2011
Yeah derby is a pretty cool stuff. I wanted to suggest it immediately I saw this thread but it seems the work is not so large, so you may use object serialization. You use the value object design pattern. Create your value object to conveniently hold entire records (which will contain all the details and pictures you need), you then serialize the value objects for each record; using a proper directory structure. You can then zip the root of the serialization output. You can name the resulting zip file "my_database.db" or something. You have your own custom database, only you know its actually a zip file.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 11:23am On Jul 14, 2011
@sayomarvel,tnx for response,its like u r talkn about the serialization of objects usn d java.io.* package but as for the my_database.db file u talked abt,is it goin 2b of the java derby embedded database or an xml file formatting.
There was a time i sent u a mail concerning a program iam writing,its abt a test engine,i sent u the codes i've written so far btu did not respond,can u recollect pls reply.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 5:31pm On Jul 15, 2011
@sayomarvel and skydancer, as regards the program, i want to implement this functionality such that when the the admin logging that is when the other tabs will be visible and active for registration and performing other activities with the software. but this is the code i have so far, tis code shows the tabs that i want to be on the application, and am still going to make other components to be active on each tab,the GUI but so far i want.
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.awt.*;
import java.sql.*;
import java.net.*;

public class PatManager extends JFrame implements ActionListener,Serializable,ItemListener{

//initializing panels
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3 =new Panel();
Panel p4=new Panel();
Panel p5=new Panel();

//initializing the string array object for sex, no of children,religion
String[] sex={"Male","Female"};
String[]religion={"Christianity","Islam","Traditional","Hinduism","Buddhisim"};
String[]nofc={"1-4","5-10","11-15","16-20"};


//declaring the socket and serversocket object
Socket socket;
ServerSocket srv;


//declaring the buttons
JButton submit,exit,update,login,searchRecords,browse,brws,brw;


//initializing the tabs
JTabbedPane tab=new JTabbedPane(JTabbedPane.TOP,JTabbedPane.SCROLL_TAB_LAYOUT);


//declaring the labels
JLabel crdno,sname,fname,dob,sx,nochild,relig,caddr,raddr,phnoI,phnII,docId,password;

//declaring the Textfields
JTextField f1,f2,f3,f4,f5,f6,f7,f8,f9,f0,f11,f12,f13,f14,f15,f16;
JPasswordField pasw;
//declaing the textareas
JTextArea a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16;

//declaring image objects for the file class
Image img;

//declaring the file class
File file;

public PatManager(){
super("Hospital Patient Manager"wink;
setSize(350,500);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


GridLayout grid5=new GridLayout(16,2);
GridLayout grid4=new GridLayout(16,2);
GridLayout grid3=new GridLayout(16,2);
GridLayout grid2=new GridLayout(8,1);
GridLayout grid1=new GridLayout(2,2);

p4.setLayout(grid2);

//initializing the buttons

submit=new JButton("Submit"wink;
exit=new JButton("Exit"wink;
update=new JButton("Update"wink;
searchRecords=new JButton("Search Records"wink;
browse=new JButton("Browse"wink;
brws=new JButton("Browse"wink;
brw=new JButton("Browse"wink;

//initializing the labels
crdno=new JLabel("Card Number"wink;
sname=new JLabel("Surname"wink;
fname=new JLabel("First Name"wink;
docId=new JLabel("Doctor's ID"wink;
password=new JLabel("Password"wink;

//initializing textfields
f1=new JTextField(20);
f2=new JTextField(20);
f3=new JTextField(20);
f4=new JTextField(20);
f5=new JTextField(20);
f6=new JTextField(20);
f7=new JTextField(20);
f8=new JTextField(20);
f9=new JTextField(20);
f0=new JTextField(20);
f11=new JTextField(20);
f12=new JTextField(20);
f13=new JTextField(20);
f14=new JTextField(20);
f15=new JTextField(20);
f16=new JTextField(20);

pasw=new JPasswordField(6);

//initializing text areas
a1=new JTextArea(6,10);

a2=new JTextArea(6,10);
a=new JTextArea(6,10);
a3=new JTextArea(6,10);
a4=new JTextArea(6,10);
a5=new JTextArea(6,10);
a6=new JTextArea(6,10);
a7=new JTextArea(6,10);
a8=new JTextArea(6,10);
a9=new JTextArea(6,10);
a10=new JTextArea(6,10);
a11=new JTextArea(6,10);
a12=new JTextArea(6,10);
a13=new JTextArea(6,10);
a14=new JTextArea(6,10);
a15=new JTextArea(6,10);
a16=new JTextArea(6,10);









//adding buttons to the actionlistener event class
submit.addActionListener(this);
exit.addActionListener(this);
update.addActionListener(this);
searchRecords.addActionListener(this);
browse.addActionListener(this);
brws.addActionListener(this);
brw.addActionListener(this);

//adding Components to the panels

p4.add(crdno);p4.add(f1);
p4.add(sname);p4.add(f2);
p4.add(fname);p4.add(f3);
p4.add(searchRecords);p4.add(exit);

p5.add(docId);p5.add(f4);
p5.add(paswd);p5.add(pasw);
p5.add(login);

//adding panels to tabs
tab.addTab("Doctors' Portal",p1);
tab.addTab("Patients Registration Portal",p2);
tab.addTab("Medical Examination Records",p3);
tab.addTab("Archives",p4);
tab.addTab("Admin",p5);
p5.setVisible(false);
this.add(tab);

}


public void actionPerformed(ActionEvent evt){
Object source=evt.getSource();
if(source==exit){
System.exit(0);}

if(source==searchRecords){



}

if(source==submit){
}

}

public void itemStateChanged(ItemEvent ev){

}

public static void main(String[]args){
new PatManager();
}
}
please reply thanks
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Fayimora(m): 5:55pm On Jul 15, 2011
This code you have here is too much so i ddnt read it. however what you want to accomplish is easy but let me make sure i understand it first. You have a software and you want to have a login panel. So anyone who wants to acces that software has to login. Ok cool.

Just have a simple class that creates a frame and does your validation. Make sure you set undecorated to true. When the user logs in, then you call a constructor that loads up the main frame, destroying the login frame. If you implement it like this then the user would see a small frame(probably 300 X 300) and after validation returns true, the form disappears automagically and yaay we have our main frame loaded up.

If you are already using the JDK7, there is a new way I "invented" taking advantage of the JLayer and "on the spot" validation.Its fr way 'cooler' but lets leave that for now.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by infoking1: 7:06pm On Jul 15, 2011
Call me
grin
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 12:37pm On Jul 16, 2011
@fayimora thanks alot i got what you are saying probably i might need to detail the program very well before i launch into it fully, but as regards to the JLayer you talked about in JDK7, can you give me a simple code snippet that implements the functionality am talking abt that is login functionality.thanks i will be expecting ur reply.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by skydancer: 1:58pm On Jul 16, 2011
@Danyl: If those are just the details you can use xml or database comfortably.

Your xml file might look like this:

<?xml version="1.0" encoding="UTF-8"?>
<Personnel>
<Employee type="permanent">
<Name>Seagull</Name>
<Id>3674</Id>
<Age>34</Age>
</Employee>
<Employee type="contract">
<Name>Robin</Name>
<Id>3675</Id>
<Age>25</Age>
</Employee>
<Employee type="permanent">
<Name>Crow</Name>
<Id>3676</Id>
<Age>28</Age>
</Employee>
</Personnel>


the following website covers how to do this in java very well:

http://www.java-samples.com/showtutorial.php?tutorialid=152

Good Luck
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 2:23pm On Jul 16, 2011
thanks alot skydancer. iwill get to the site and iwill get back to you.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by SayoMarvel(m): 12:59pm On Jul 22, 2011
@Danyl I'm so sorry. Maybe your email ended up in my spam folder.
The derby and serialization are two different approaches. If your data is simple enough (and you want to get your hands dirty), you can use the serialization approach. I provided that approach because its easy (learning curve is friendly). Send the email again. I can't guarantee an immediate response though, because of ongoing exams.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 2:56pm On Jul 22, 2011
thanks alot sayomarvel.i will resend the message, there was a time when my system got infected with a virus but couldn't get retain the files cos it must have been infected but i will send the copy from my sent mails.
as regards to the issue on the program iam writing i will get back to you when i apply those changes. tanks.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Fayimora(m): 1:18am On Jul 23, 2011
Hey man sorry, finally got to this thread, too many threads to look at combined with other stuffs, Have you finished ur login form?
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 10:54am On Jul 23, 2011
hello fayimora this is how what i have on the logging interface,
i am just getting familiar with the jdk1.7 the new release, can you kindly give a code snippet based on the JLayer class you talked about. thanks

I ATTACHED THE FILE HERE FOR YOUR VIEW

Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Fayimora(m): 10:57am On Jul 23, 2011
Hmm woud take a look at it, yes i can give you a snippet but unfortunately i have removed he JDK7 from my system, When its officially out fo download I would rewrite it and pass it, by the way why do you anna use jdk7? I can still write it tho and then you test it yasef
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Fayimora(m): 11:15am On Jul 23, 2011
Ok it looks ok but very redundant. You have some things here that you shouldn't.

1 --> You dont want someone to be able to bypass your login for without actually login in. So set undecorated to true. Flowlayout?? Naaa not good enough, set your layout to GridLayout(3,2)


2 --> You are using some "almost fully deprecated" stuff

Hashtable hash;
Vector v;


Gone are the days of those. You need to us them generically.
Hashtable<T> hash = new Hashtable<T>();


3 --> I really dont see the use of those data-structures, If you have your username and passwords in an XML file or database, just check if they exist rather than loading them first, saves time.

4 --> When you successfully login, how do you load up details of the logged in user or whatever? You need to pss the username and password via the constructor of PatManager or take in a different stuff and pass, and then you can use it to pull out data.

The way i would have done it is:
-> a successful login
-> pass username and password to a utility called `LogedInuser` or anything better. This class would pull all necessary data from the database/xml/txt/yaml and load them into variables. This is helpful because I don't have to waste time loading stuff like that again during the actual program's runtime
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Fayimora(m): 11:19am On Jul 23, 2011
Danyl:


//declaring the Textfields
JTextField f1,f2,f3,f4,f5,f6,f7,f8,f9,f0,f11,f12,f13,f14,f15,f16;
JPasswordField pasw;
//declaing the textareas
JTextArea a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16;

//initializing textfields
f1=new JTextField(20);
f2=new JTextField(20);
f3=new JTextField(20);
f4=new JTextField(20);
f5=new JTextField(20);
f6=new JTextField(20);
f7=new JTextField(20);
f8=new JTextField(20);
f9=new JTextField(20);
f0=new JTextField(20);
f11=new JTextField(20);
f12=new JTextField(20);
f13=new JTextField(20);
f14=new JTextField(20);
f15=new JTextField(20);
f16=new JTextField(20);

pasw=new JPasswordField(6);

//initializing text areas
a1=new JTextArea(6,10);

a2=new JTextArea(6,10);
a=new JTextArea(6,10);
a3=new JTextArea(6,10);
a4=new JTextArea(6,10);
a5=new JTextArea(6,10);
a6=new JTextArea(6,10);
a7=new JTextArea(6,10);
a8=new JTextArea(6,10);
a9=new JTextArea(6,10);
a10=new JTextArea(6,10);
a11=new JTextArea(6,10);
a12=new JTextArea(6,10);
a13=new JTextArea(6,10);
a14=new JTextArea(6,10);
a15=new JTextArea(6,10);
a16=new JTextArea(6,10);

Wow didn't you get tired of typing the same thing over and over? Just create an array of type JTextField/JTextArea and use a for loop to initialise them all
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 4:15pm On Jul 23, 2011
thanks for opening my eyes. i've been into so many things that is affecting my thought but i do that.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by iGravity(m): 1:04pm On Aug 03, 2011
Look into SQLite3 for simple database integration. It supports SQL and it can ship with your application - doesn't have a fat ass that requires a server like MySQL
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by Danyl(m): 12:44pm On Aug 04, 2011
@fayimora thanks for taking your time to post this info to me actually i realy dont want to use the datastructures but the problem is just that implementing the xml parsing of files and authenticating users is a bit of a problem right now.
i have alot of stuffs that i really wanna use the xml style to handle but right now i have to delve into the xml stuff, but in the mean time can you stuff highlight a simple way of authenticating users with xml and how to parse the file and bundle it with the application, i know this will take your time but just try and understand me.thanks alot

@iGravity: thanks for your comment but what do you see to the use of a java derby db.
Re: Helo House,how Can I Bundle A Database File Into My Desktop Applicatn by megaplaza(m): 10:42am On Aug 06, 2011
@danyl, i don't find java derby user friendly or maybe i wasn't patient enough to learn it. I think it has high learning curve. Why not use H2 database, it's as easy as using mysql and it's well documented. As for login interface, this is how i handle mine. I created login panel, then admin interface panel. I set the frame panel to the FRAME getContentPane then authenticates login, if valid i then remove all panel from the frame's getcontentpane using removeall(), then add the admin interface panel to getcontentpane and uses getcontentpane().validateUI() or so to refresh the user interface to show the admin panel.esh the user interface to show the admin panel.

(1) (Reply)

Introduction To Database Design (video Tutorial For Beginners) / HELP I Need A Visual Studio 2012 File / Facebook Launches Techprep: ‘there Will Be Over 1M Programming Jobs By 2020’

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 54
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.