java连接informix数据库 老报错~是什么问题呀?
import java.sql.*;
public class TestInformix {
public static void main(String[] args) {
Connection conn = null;
DatabaseMetaData dmd = null;
try {
Class.forName( "com.informix.jdbc.IfxDriver ");
conn = DriverManager.getConnection( "jdbc:informix-sqli://172.16.193.15:1526/inlineDB:INFORMIXSERVER=ds_prowellnb ", "informix ", "inline ");
dmd = conn.getMetaData();
System.out.println(dmd.getDatabaseProductVersion());
System.out.println(dmd.getDatabaseProductVersion());
conn.close();
}catch (
ClassNotFoundException e) {
System.err.print(e);
}catch (
SQLException e) {
System.err.print(e);
}
}
}
Eclipse中报的错:
java.lang.ClassNotFoundException: com.informix.jdbc.IfxDriver
------解决方案--------------------我是用Lomboz eclipse 写的;informix中的setup.jar已经添加进来了..
------解决方案--------------------应该来看是没有找到infomix的jdbc驱动.
------解决方案--------------------jar包的路径不对
------解决方案--------------------请问这个问题是怎么解决的?我现在也遇上这个问题,用Eclipse lomboz jboss:
test.jsp代码:
<%@ page contentType="text/html;charset=gb2312"%>;
<%@ page import="java.sql.*"%>;
<%@ page language="java" %>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Lomboz JSP</title>
</head>
<body bgcolor="#FFFFFF">
<%
java.sql.Connection conn;
java.lang.String strConn;
try {
Class.forName("com.informix.jdbc.IfxDriver").newInstance();
conn = java.sql.DriverManager.getConnection("jdbc:informix-sqli://192.0.0.1:23008/busniess:INFORMIXSERVER=aa_tcp;user=aa;password=aa");
%>
连接INFORMIX-BUSNIESSANA成功!
<%
} catch (
java.sql.SQLException e) {
out.println(e.toString());
}
%>
</body>
</html>
测试的时候显示:
HTTP ERROR: 500 com.informix.jdbc.IfxDriver
RequestURI=/JdbcStudyBasic/test.jsp
在控制台上显示:
16:00:06,828 WARN [jbossweb] WARNING: Exception for /JdbcStudyBasic/test.jsp
java.lang.Class
NotFoundException: com.informix.jdbc.IfxDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at org.mortbay.http.ContextLoader.loadClass(ContextLoader.java:224)
at org.mortbay.http.ContextLoader.loadClass(ContextLoader.java:197)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:198)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.apache.jsp.