Practical Eclipse, Jigloo, PostgreSQL, JDBC Development Database Query Application Start

xiaoxiao2021-03-06  17

Practical Eclipse, Jigloo, PostgreSQL, JDBC Development Database Query Application Start

1 Installing the GNU / Linux for installing the Eclipse author first after downloading some GTK -related package, find the Eclipse installation file of the GTK under Linux on the Eclipse home page.

2. The plugin author has two plugins for the GUI Design Tool Jigloo, Home: http://cloudgarden.com/jigloo/

One is packaging tool Fat Jar Exporterhttp: //fjep.sourceforge.net/

3 postgreSQLHTTP: //www.postgresql.org/ The author is installed 8.0, according to the instruction, compile, install, establish the database, start the service, did not encounter too much problem

4 jdbchttp: //jdbc.postgreSQL.org author downloaded 8.0 JDBC

5. Eclipse project settings, code

Adding PostgreSQL-8.0-310.jdbc3.jar Adding Projects (Add External Jar)

After adding the following code, you can see that the JDBC connection is successful, the author is good. Successful

String username = username "; String password = password"; String url = "jdbc: postgresql: // localhost / testdb"; try {Class.forName ( "org.postgresql.Driver");} catch (ClassNotFoundException e1) {/ / TODO Auto-generated catch block e1.printStackTrace ();} try {Connection db = DriverManager.getConnection (url, username, password); Statement st = db.createStatement (); ResultSet rs = st.executeQuery ( "SELECT * FROM pg_user "); while (rs.next ()) {System.out.print (" Column 1 returned "); System.out.println (rs.getString (1));} rs.close (); st.close (); // Todo Add your code for menuitem3.widgetSelected} catch (sqlex) {// Todo auto-generated catch block e.printstacktrace ();}}

转载请注明原文地址:https://www.9cbs.com/read-41249.html

New Post(0)