你创建odbc了么;
应该是你的数据库连接不成功造成的:
给你一个简单的例子:
public Connection createConnection()
{
readFileInfo readfile = new readFileInfo();
String ip = readfile.getFileInfo("ip");
String database = readfile.getFileInfo("database");
//定义jdbc连接oracle的url
String strUrl="jdbc:oracle:thin:@" +ip.trim() +":1521:" + database + ""; /**
创建数据库的连接,返回connection
*/ //定义数据库连接的变量
Connection connection=null;
try
{
//定义oracle的driver
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String user=null;
String password = null;
user = readfile.getFileInfo("user");
password = readfile.getFileInfo("password");
//连接数据库
connection = DriverManager.getConnection(strUrl,user.trim(),password.trim());
}
catch (Exception e)
{
System.out.println(e.toString());
}
return connection;
}
应该是你的数据库连接不成功造成的:
给你一个简单的例子:
public Connection createConnection()
{
readFileInfo readfile = new readFileInfo();
String ip = readfile.getFileInfo("ip");
String database = readfile.getFileInfo("database");
//定义jdbc连接oracle的url
String strUrl="jdbc:oracle:thin:@" +ip.trim() +":1521:" + database + ""; /**
创建数据库的连接,返回connection
*/ //定义数据库连接的变量
Connection connection=null;
try
{
//定义oracle的driver
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String user=null;
String password = null;
user = readfile.getFileInfo("user");
password = readfile.getFileInfo("password");
//连接数据库
connection = DriverManager.getConnection(strUrl,user.trim(),password.trim());
}
catch (Exception e)
{
System.out.println(e.toString());
}
return connection;
}
解决方案 »
- 如何添加二级域名
- 新手求帮助,希望各位高手帮帮忙,在线等待。。
- struts2 Ajax校验的问题
- 高分,很急的简单问题,一个img标签的问题
- Firefox是用java开发的吗?为什么不用安装jre?编译进去了?
- 100分求在线考试系统一个
- Spring + Velocity开发ajax应用时遇到的问题!
- 在WEBLOGIC8.1中该如何设置虚拟目录
- 急寻电子书<<Java XML程序员参考手册>><<Java开发指南——应用XML和JSP开发电子商务>>
- JBuilder 的问题
- JBuilder和Weblogic的一个问题,在线等待,马上结账。
- 谁有jbuilder8的serial number 和 key ,谢谢!!!!
我感觉是外面的show.jsp文件中的
ResultSet executeQuery("select * from 表")没有被执行
我用jsp中直接连数据库就是通的
为什么?