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
access database from java applicationhow can we access database from application program
Page 1 of 1
3 Replies - 886 Views - Last Post: 04 December 2008 - 09:33 PM
Replies To: access database from java application
#3
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);
}
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);
}
#4
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 ?
Are you expecting us to write all your GUI ?
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|