myeclipse6.5连接PostgreSQL数据库
来源:互联网 发布:淘宝网怎么推广 编辑:程序博客网 时间:2024/06/07 02:34
接着上一篇文章,成功安装完PostgreSQL数据库服务器后,就是开始用myeclipse6.5连接PostgreSQL数据库的java程序了。
首先,需要jar包。
package com.test;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;import org.postgresql.*;public class testdb { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println( " this is a test " ); try { System.out.println( " try link db " ); Class.forName( "org.postgresql.Driver" ).newInstance(); //Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://localhost:5432/postgres" ; Connection con = DriverManager.getConnection(url, "postgres" , "step" ); Statement st = con.createStatement(); String sql = " select * from testtable " ; ResultSet rs = st.executeQuery(sql); System.out.println( " try link db " ); while (rs.next()) { System.out.println( " try show db " ); System.out.print(rs.getInt( 1 )); System.out.println(rs.getString( 2 )); } rs.close(); st.close(); con.close(); } catch (Exception ee) { System.out.print(ee.getMessage()); } }}
- myeclipse6.5连接PostgreSQL数据库
- VB6连接PostgreSQL数据库
- 远程连接postgreSQL数据库
- postgreSQL连接数据库
- 菜刀连接postgresql数据库
- ADOConnection 连接PostgreSQL数据库
- C#连接postgresql数据库
- Java连接PostgreSQL数据库
- pgAdmin连接postgresql数据库
- Java连接postgresql数据库
- hibernate 连接postgresql数据库
- JAVA连接PostgreSQL数据库
- MyEclipse6.6 连接MySQL的数据库配置
- MyEclipse6.6远程连接Mysql数据库服务器
- MyEclipse6.6远程连接Mysql数据库服务器
- PHP 连接PostgreSql数据库代码
- postgresql jdbc 连接数据库测试
- JDBC连接之PostgreSQL数据库
- 随便说说
- SQL分页语句
- irssi for windows
- Own brand of triumph and made famous Chongqing International Auto Show 2010
- 兼容问题 CSS浏览器 IE6.0,ie7.0与Firefox的CSS兼容性问题
- myeclipse6.5连接PostgreSQL数据库
- form表单的各种input的submit传值
- AS3.0 俄罗斯方块
- VS2008 下 ACE / TAO 的编译 for windows
- 习题10.9
- Item9: Never call virtual functions during construction or destruction
- Six Steps to write an ILE C CGI program
- Spring 和 Hibernate的集成
- Java 俄罗斯方块