最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jsp 连接Oracle 数据库四种方法
时间:2011-02-18 编辑:简简单单 来源:一聚教程网
package dbbean;
import java.sql.*;
public class contactbean{
private connection con; //初始化连接。
public contactbean() {
try { class.forname("oracle.jdbc.driver.oracledriver").newinstance();
string url="jdbc:oracle:thin:@localhost:1521:hcm";
string user="jsp教程dev";
string password="19831007";
con= drivermanager.getconnection(url,user,password);
}
catch (instantiationexception e)
{ // todo auto-generated catch block
e.printstacktrace();
} catch (illegalaccessexception e)
{ // todo auto-generated catch block
e.printstacktrace();
}
catch(classnotfoundexception e)
{
system.out.println("driver not found!");
con=null;
}
catch(sqlexception e)
{ con=null; }
}
//代码二
class.forname("oracle.jdbc.driver.oracledriver").newinstance();?
string?url="jdbc:oracle:thin:@localhost:1521:orcl";?
//orcl为你的数据库教程的sid?
string?user="scott";?
string?password="tiger";?
connection?conn=?drivermanager.getconnection(url,user,password);?//
class.forname("oracle.jdbc.driver.oracledriver").newinstance();?
string?url="jdbc:oracle:thin:@localhost:1521:orcl";?
//orcl为你的数据库的sid?
string?user="scott";?
string?password="tiger";?
connection?conn=?drivermanager.getconnection(url,user,password);?
statement?stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable
%>
-
上一个: JSP中文乱码的处理方法
-
下一个: jsp url地址中文传输问题解决方法
相关文章
- Oracle数据库和JSP连接注意细节 11-26
- SpringBoot测试配置属性与web启动环境解析 10-24
- vue中将el-switch值true、false改为number类型的1和0解析 10-24
- Vue中的路由配置项meta使用解读 10-24
- SpringBoot自定义bean绑定解析 10-24
- SpringBoot常用计量与bean属性校验和进制数据转换规则解析 10-24