• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connect java with database through java.swing*

 
besian hoxha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have a look at the Java™ Tutorials, which has lots about using Swing (not swing). Try here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic