| | |
Swings with database
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 99
Reputation:
Solved Threads: 4
I wish to create an application using swing to update data to the database. I will need three buttons add, modify and delete.
i have so far created JDBC connection with Ms acess. i have also created a textfield where i will enter data like this...
i wish to connect swing(applet) to database.Also i am not able to view text through the paint function on the applet.
my jdbc
i would love if someone helps with this code(modify it) also something about "modify"button(its nature)
i have so far created JDBC connection with Ms acess. i have also created a textfield where i will enter data like this...
JAVA Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; /*<applet code="textfield" width=300 height=200></applet>*/ public class textfield extends JApplet implements ActionListener { JTextField jtf; public void init() { Container cp=getContentPane(); cp.setLayout(new FlowLayout()); jtf=new JTextField(15); cp.add(jtf); } public void actionPerformed(ActionEvent ae) { repaint(); } public void paint(Graphics g) { g.drawString(jtf.getText(),100,80); } }
i wish to connect swing(applet) to database.Also i am not able to view text through the paint function on the applet.
my jdbc
JAVA Syntax (Toggle Plain Text)
import java.sql.*; public class Test4 { public static void main(String[] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String dataSourceName = "mdbTest1"; String dbURL = "jdbc:odbc:" + dataSourceName; Connection con = DriverManager.getConnection(dbURL, "",""); Statement s = con.createStatement(); s.execute("create table TEST1223 ( id integer, name VARCHAR(32) )"); s.execute("insert into Test1223"+"(id,name)"+"values('1001','nikhil')"); s.execute("insert into Test1223"+"(id,name)"+"values('1002','ketan')"); s.close(); // close the Statement to let the database know we're done with it con.close(); // close the Connection to let the database know we're done with it } catch (Exception err) { System.out.println("ERROR: " + err); } } }
i would love if someone helps with this code(modify it) also something about "modify"button(its nature)
1
#2 Oct 16th, 2009
MS Access is file based (i.e. no remote connections, local file access needed) and Applets do not have access to the local file system. A complete redesign is in order.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
0
#4 Oct 16th, 2009
I think that you can write a server/client solution to get it to work. The client connects to the server which returns the content of the database. I did something like that when I needed my applet to read from a database, but I don't remember all the details.
---------------------------
333 - halfway to hell
333 - halfway to hell
0
#5 Oct 16th, 2009
•
•
•
•
I need more details. I don't understand what you are actualy doing. The best method would be to make a JTable in which you can see your database table records. Then you can go further. I mean how can you modify something if you can't see what row u actualy modify? (I'm guessing)
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
0
#6 Oct 16th, 2009
•
•
•
•
I think that you can write a server/client solution to get it to work. The client connects to the server which returns the content of the database. I did something like that when I needed my applet to read from a database, but I don't remember all the details.
Of course you can build your own client/server protocol and connection to enable connection to MS Access, but why? Why pay the hefty license and software costs only to have to build your own (possibly buggy) access routines in order to be able to even use it when there are a plethora of free client/server DBs out there, and most of them are better than MS Access in the first place.
Last edited by masijade; Oct 16th, 2009 at 5:31 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
0
#7 Oct 16th, 2009
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jun 2009
Posts: 99
Reputation:
Solved Threads: 4
The question i have is: Create a java application which will add, modify,delete records from employee database.The database has 3 fields emp_id, empname and department location.All information accepted from GUI and stored in the database(hint:use jdbc)
so in the first part of my code i was trying to create a textfield for data entry. When i enter text in the textfield and click the add button the information should get updated in the database.We will be using MS access as the database.
In the next code i have just demonstrated what code i will be using as a response to the GUI event.
It need not be an applet but any GUI java application.dialog box, Jpane etc.(calling functions using main())
so in the first part of my code i was trying to create a textfield for data entry. When i enter text in the textfield and click the add button the information should get updated in the database.We will be using MS access as the database.
In the next code i have just demonstrated what code i will be using as a response to the GUI event.
It need not be an applet but any GUI java application.dialog box, Jpane etc.(calling functions using main())
0
#9 Oct 16th, 2009
Then normal swing standalone app.
A preparedstatement, its setString method, and the textfields getText method.
That should get you started.
A preparedstatement, its setString method, and the textfields getText method.
That should get you started.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Packaging Application and Database (C#)
- update sql server data database in c# (C#)
- Add a new record to access database in VB 2005 (VB.NET)
- Help im displaying image from database in java (Java)
- Website and Database Programmer Wanted in Scottsdale, AZ (Web Development Job Offers)
- News Story: UK government proposes big brother database of every email sent by Brits (Network Security)
- News Story: Security system uses database DNA (Database Design)
- swings,aplet,jsp example (Java)
Other Threads in the Java Forum
- Previous Thread: Show Stack using JLabel
- Next Thread: where should i start
| Thread Tools | Search this Thread |
2dgraphics 3d @param affinetransform android api apple applet application arc arguments array arrays automation banking binary binarytree bluetooth byte chat chatprogramusingobjects class client code color compare component count database derby design detection eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui guitesting helpwithhomework html ide if_statement image integer interface j2me java java.xls javadesktopapplications javaprojects jni jpanel julia keytool keyword linux list macintosh map method methods mobile netbeans newbie object os pong problem producer program programming project projectideas read recursion reference replaysolutions rim scanner server set size sms sort sql string swing terminal threads transforms tree ui unicode web windows






