教程学院
图像设计 多媒体类 机械制图 办公软件 操作系统 系统编程 网站编程 网页制作 数据库类 网络路由 网络工程 网络安全 考试认证
firefox火狐浏览器下载
酷网学院
CAD
AutoCad Cam350 ProEngineer GCcam MATLAB Unigraphics SolidWorks CAXA Solid3000 Cimatron EdgeCAM
系统
安全 防火墙 病毒 WinXP Win2003 Vista
数据库
编程
网络
精彩图库
  当前位置: 库库中文网 · 数据库类教程 · Informix教程

JDBC连接Informix IDS

学院最新推荐文章
教程推荐
『JDBC连接Informix IDS』如果文章有大量图片,显示会较慢,请等待图片下载完成
 
点击数: 更新时间:2005-12-7 

Informix 的JDBC驱动是type 4的方式

1.环境说明

OS: Windows XP

Informix: IDS V10.00.TC1

JDBC: Informix JDBC Embedded SQLJ V2.20JC2

2.JDBC配置

安装完Informix JDBC后把ifxjdbc.jar路径加到CLASSPATH环境变量中,比如CLASSPATH=C:\ifxjava_home\lib\ifxjdbc.jar;....

在安装完后的目录中有doc目录,里面有详细的文档说明。还有demo目录,里面有可以参考的源代码

3.DEMO代码

下面的源代码,是参考了(\doc\release\oij_jdbc_migration.html)

通过Java使用JDBC连接IDS V10.0

import java.sql.*;

import java.util.*;

public class ifx_con

{

public static void main(String[] args)

{

Connection conn;

String url = "jdbc:informix-sqli://IBM-HENRY:1526/sample:informixserver=ol_henry;user=henry;password=happyday";

System.out.println("Informix JDBC connect test.");

try

{

// Load the Informix JDBC Driver

//DriverManager.registerDriver((Driver) Class.forName("com.informix.jdbc.IfxDriver").newInstance());

Class.forName("com.informix.jdbc.IfxDriver");

//Create and open a server/database connection

conn = DriverManager.getConnection(url);

System.out.println("JDBC driver name: " + conn.getMetaData().getDriverName());

//Queries that return more than one row

Statement query = null;

ResultSet rs = null;

String st = new String();

try

{

query = conn.createStatement();

rs = query.executeQuery("select * from customer");

while (rs.next())

{

System.out.println(rs.getString(2));

}

rs.close();

query.close();

}

catch (SQLException exce)

{

System.out.println("Caught: " + exce.getErrorCode());

}

conn.close();

}

catch (ClassNotFoundException drvEx)

{

System.err.println("Could not load JDBC driver");

System.out.println("Exception: " + drvEx);

drvEx.printStackTrace();

}

catch(SQLException sqlEx)

{

while(sqlEx != null)

{

System.err.println("SQLException information");

System.err.println("Error msg: " + sqlEx.getMessage());

System.err.println("SQLSTATE: " + sqlEx.getSQLState());

System.err.println("Error code: " + sqlEx.getErrorCode());

sqlEx.printStackTrace();

sqlEx=sqlEx.getNextException();

}

}

}

}



作者:无 来源:无
】【关闭窗口
·上页:
·下页:
相关文章
     数据库类教程 - Informix教程
推荐教程Informix Dynamic Server数据库
推荐教程Informix数据库调优办法
推荐教程JDBC连接Informix IDS
推荐教程Informix sysmaster表详细解说
推荐教程配置和完成Informix ON-Bar地备
推荐教程online地备份详细解说
推荐教程配置Informix动态服务器里面CPU
推荐教程备份Informix-Online数据库三法
推荐教程Informix动态服务器表分片策略地
推荐教程OnLine非正常结束后处理办法
推荐教程Win xp下地Informix connect配置
推荐教程用shell完成Informix地性能监控
精彩图片汇集
advertisement
关于站点 - 广告服务 - 联系我们 - 版权隐私 - 免责声明 - 合作伙伴 - 程序支持 - 网站地图 - 返回顶部
网站文本地图
版权所有:库库中文 2005-2007 欢迎各种媒体转载我们的原创作品[转载请注明出处]
copyright © 2005-2008 www.QQGB.com online services. all rights reserved. 蜀ICP备05015578
Template designed by Virus. Optimized for 1024x768 to Firefox,Opera and MS-IE6. Site powered by EQL.
红盾
热爱电脑,热爱生活
拥有电脑,拥有生命
让我们享受拥有电脑的时光