最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jsp 连接Oracle 数据库四种方法
时间:2022-06-29 03:15:16 编辑:袖梨 来源:一聚教程网
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
%>
相关文章
- linux怎么在history命令中前面显示日期? 09-26
- linux系统怎么快速切换文本模式和X环境? 09-26
- linux中怎么安装bleachbit清理系统拉圾? 09-26
- linux怎么修改账户头像? linux修改登录用户头像的方法 09-26
- linux怎么下载安装腾讯Tim? 09-26
- linux文件默认打开方式该怎么更改? 09-26