aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Connect java with database through java.swing* Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Connect java with database through java.swing*" Watch "Connect java with database through java.swing*" New topic
Author

Connect java with database through java.swing*

besian hoxha
Greenhorn

Joined: May 21, 2012
Posts: 3

Hello to everyone,

I'm beginner in Java programming..
I have an exam with programming, i have a task to create a application with java.swing*, through swing* , I have to create a connection with database oracle.
I need a code with swing, a text field, when i type a database query, this query will execute and will get the data in database oracle and will show them in application.

I hope this will be understating for you.

Thanks for your time.
Respect.
Habeeb Shaikh
Ranch Hand

Joined: Nov 23, 2008
Posts: 48
hi,
1. Initially you have to write code for your driver registration.like Class.forName(oracle driver)
2.You will get connection object
3.You will get statement object
4.execute your query
5.You will get record set.
6.Pick up a record form record set and set it to your swing component for example textField like that textField.set(value).

If you follow above step then it will work smoothly. let me know if you will struck anywhere.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39877
    
  28
Welcome to the Ranch

I would recommend you start by getting the database connection working with a Java™ program running on the command line. And I recommend the Java Tutorials to help learn how to do that.
Then you can add Swing (not swing*) components later.
besian hoxha
Greenhorn

Joined: May 21, 2012
Posts: 3
Hi,

Thanks for quick replay

I connected code with database oracle through drivers, and when I write a query in code , a string, i take the result about that query what i asked.

What I don't know is swing. As I said, i need to open a window (application based on swing ), and in that window which must contain a text field, so, when i type a query in that field, i must get the result from database, same as i get from string which wrote in code.
What I just want to ask you guys is, if someone had a task like that, or have a code like that..

I'll thankful for any help..

Thanks a lot
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39877
    
  28
You can have a look at the Java™ Tutorials, which has lots about using Swing (not swing). Try here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connect java with database through java.swing*