• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Connect java with database through java.swing*

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 75839
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 75839
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can have a look at the Java™ Tutorials, which has lots about using Swing (not swing). Try here.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic