使用JDBC数据源连接池方式连接Oracle数据库的方法

[数据库] 时间:2025-11-05 11:47:31 来源:益强IT技术网 作者:系统运维 点击:155次
使用JDBC数据源连接池方式连接Oracle数据库的方法
复制使用JDBC数据源连接池方式连接数据库(效率高)   用这种方式连接数据库之前,使用数据数据首先需要配置TOMCAT服务器目录下的源连文件\tomcat5\conf\context.xml文件:   <Contextreloadable="true"> <WatchedResource>WEB-INF/web.xml</WatchedResource> <Resourcename="jdbc/oracle"auth="Container"type="javax.sql.DataSource" maxActive="100"maxIdle="30"maxWait="10000"username="scott"password="tiger" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@192.168.1.3:1521:ora92"/> </Context> 配置完后将oracle驱动程序类classes12.jar拷贝到\tomcat5\common\lib目录下即可。在这里强调一下这个问题,接池我就是式方法遇到这种问题的,企商汇最后就是连接这样给解决的。之前我用了ojdbc5.jar驱动类文件总是使用数据数据不能够建立连接的,源码下载而且出现这样的源连问题:Cannot create JDBC oracle driver of class  for connect URL jdbc:oracle:thin:@192.168.1.3:1521:ora92"。希望这篇文章给读者有点启发。接池我的式方法QQ号码:89262840   import javax.naming.Context;   import javax.naming.InitialContext;   import javax.sql.DataSource;   String sql = "insert into users(username,password) values(?,?)";   String username = request.getParameter("username");   try {      Context context=new InitialContext();   DataSource ds=(DataSource)context.lookup("java:/comp/env/jdbc/oracle");   Connection conn=ds.getConnection();   PreparedStatement ps = conn.prepareStatement(sql);   ps.setString(1, StringUtil.filterHtml(username));   ps.setString(2, StringUtil.filterHtml(request.getParameter("password")));   result = ps.executeUpdate();   ps.close();   conn.close();      } catch (NamingException e) {   e.printStackTrace();   } catch (SQLException e) {   e.printStackTrace();   }   1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.

(责任编辑:IT科技类资讯)

    虚拟机内存,必须是4的倍数 使用文本编辑器打开虚拟机的安装目录下的“xxxxxx.vmx”文件,按照以下进行修改复制代码代码如下:vmci0.present = FALSE对于Ubuntu Unity 下找回系统托盘,只需要将程序纳入白名单中即可。但是在Ubuntu 13.04 中,原本的方法行不通,因为配置文件中没有com.canonical.Unity.Panel 选项。这个时候,需要把这个选项重新激活,使用下面的PPA即可:sudo add-apt-repository ppa:timekiller/unity-systrayfixsudo apt-get updatesudo apt-get upgrade完成之后,注销或者重启。然后就可以按照以前的方法设置白名单了(下面是设置全部):gsettings set com.canonical.Unity.Panel systray-whitelist [all]Ubuntu Unity 下无法显示QQ、Pidgin 等系统托盘的图标的解决方法这是由于在Unity中,Ubuntu对系统托盘采取了白名单机制,只有在白名单内的程序才能在系统托盘处显示图标。假如你想所有的程序都可以显示,则在终端运行下面命令:gsettings set com.canonical.Unity.Panel systray-whitelist [all]若你想自定义程序的话,运行下面的命令(YOUR_APPLICATION是程序名):gsettings set com.canonical.Unity.Panel systray-whitelist “[JavaEmbeddedFrame, Mumble, Wine, YOUR_APPLICATION]“还原到系统默认状态:gsettings set com.canonical.Unity.Panel systray-whitelist [JavaEmbeddedFrame, Mumble, Wine, Skype, hp-systray]Ubuntu 13.04 下默认没有com.canonical.Unity.Panel 选项,需要安装:sudo add-apt-repository ppa:timekiller/unity-systrayfixsudo apt-get updatesudo apt-get upgrade成功后再执行上诉方法即可。
    相关内容
    精彩推荐
    热门点击
    友情链接