access database from java application

how can we access database from application program

Page 1 of 1

3 Replies - 1083 Views - Last Post: 04 December 2008 - 09:33 PM Rate Topic: -----

#1 maya_bs1985  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-December 08

access database from java application

Posted 03 December 2008 - 02:25 AM

hi ,
i have dought in my project,
am crate a database ,
then i write one application in java,in that i create one button,now we want when i click button,that will acess database data,and stored in another frame,
pease help me,its urgent for my project

thank you
Is This A Good Question/Topic? 0
  • +

Replies To: access database from java application

#2 Hurshai  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 51
  • Joined: 14-September 08

Re: access database from java application

Posted 03 December 2008 - 03:53 AM

JDBC?
Was This Post Helpful? 0
  • +
  • -

#3 ivantono_ok  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-December 08

Re: access database from java application

Posted 04 December 2008 - 09:18 PM

i have write this code to access a postgresSQL database and working properly, where user and pass is user and password on u re database
other database seemly like this
try{
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test",user,pass);

} catch(java.sql.SQLException se) {
JOptionPane jfo = new JOptionPane(se.getMessage(),JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = jfo.createDialog(null, "Connection");
dialog.setModal(true);
dialog.setVisible(true);

//System.exit(1);
} catch(ClassNotFoundException ce) {
JOptionPane jfo = new JOptionPane(ce.getMessage(),JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = jfo.createDialog(null, "Connection");
dialog.setModal(true);
dialog.setVisible(true);


//JOptionPane.showMessageDialog(null,ce.getMessage(),"Connection",JOptionPane.WARNING_MESSAGE);
//System.exit(1);
}
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: access database from java application

Posted 04 December 2008 - 09:33 PM

So you connected to it or not ?
Are you expecting us to write all your GUI ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1