网站建设资讯

NEWS

网站建设资讯

oracle代码怎么写,oracle教程 菜鸟教程

java 实现 jdbc连接oracle 数据库的java代码怎么写

package com.jdbc.test;

站在用户的角度思考问题,与客户深入沟通,找到新平网站设计与新平网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、网站制作、企业官网、英文网站、手机端网站、网站推广、主机域名网站空间、企业邮箱。业务覆盖新平地区。

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

public class JDBCTest {

public static void main(String[] args) throws Exception {

//1.加载驱动

//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

//Class.forName("com.mysql.jdbc.Driver");

Class.forName("oracle.jdbc.driver.OracleDriver");

//2.创建数据库连接对象

//Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=db","sa","sqlpass");

//Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db?useUnicode=truecharacterEncoding=UTF-8","root","123456");

Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","Oracle123");

//3.创建数据库命令执行对象

Statement stmt = conn.createStatement();

// PreparedStatement ps = conn.prepareStatement("select * from t_user");

//4.执行数据库命令

ResultSet rs = stmt.executeQuery("select * from t_user");

// ResultSet rs = ps.executeQuery();

//5.处理执行结果

while (rs.next()) {

int id = rs.getInt("id");

String username = rs.getString("username");

String password = rs.getString("password");

System.out.println(id + "\t" + username + "\t" + password);

}

//6.释放数据库资源

if (rs != null) {

rs.close();

}

// if (ps != null) {

// ps.close();

// }

if (stmt != null) {

stmt.close();

}

if (conn != null) {

conn.close();

}

}

}

这是以前写的3中数据库的链接已经测试过了。

oracle按条件进行循环的代码怎么编写

begin

v_cnt number:=0;

loop

delete from a where rownum=100000;

v_cnt:=SQL%ROWCOUNT;

commit;

exit when v_cnt=0;

end loop;

end;

java 连接oracle rac c3p0代码怎么写

不是很懂你的意思

c3p0连接数据库跟连接其他的数据库是一样的啊

配置数据源,绑定数据源,再就是与其他的框架整合的问题

数据源配置:

driverClass=oracle.jdbc.driver.OracleDriver

jdbcUrl=jdbc:oracle:thin:@localhost:1521:orcl

user=sys

password=sun123

c3p0配置:

!-- c3p0 --

bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"

property name="driverClass" value="${driverClass}"/

property name="jdbcUrl" value="${jdbcUrl}"/property

property name="user" value="${user}" /

property name="password" value="${password}"/

/bean

oracle数据库求写完整代码

6

declare

s int;

begin

s := 1;

for s in 1 .. 100 loop

if s = 33 or s = 74 or s = 96 then

null;

else

dbms_output.put_line(s);

end if;

end loop;

end;

7没看懂

8

declare

n int;

s int;

begin

n := 1;

s := 0;

for n in 1 .. 100 loop

if mod(n, 2) = 1 then

s := s + n;

else

null;

end if;

end loop;

dbms_output.put_line(s);

end;

SOS!!!怎样写连接ORACLE数据库的代码?

============ORACLE 8i============================

Class.forName ("oracle.jdbc.driver.OracleDriver");

Connection conn =

DriverManager.getConnection ("jdbc:oracle:thin:@myhost:1521:orcl",

"scott", "tiger");

=============MySQL=================================

Class.forName("org.gjt.mm.mysql.Driver").newInstance();

conn = DriverManager.getConnection("jdbc:mysql://myhost:3306/dbname","user","passwd");

============InfoMax================================

Class.forName("com.informix.jdbc.IfxDriver");

conn = DriverManager.getConnection("jdbc:informix-sqli://myhost:1533:informixserver=myserver;user=rdtest;password=test");

============InforMix================================

Class.forName("com.informix.jdbc.IfxDriver");

conn = DriverManager.getConnection("jdbc:informix-sqli://myhost:1533:informixserver=myserver;user=rdtest;password=test");

=============SQLServer2000=========================

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

Connection conn = DriverManager.getConnection

("jdbc:microsoft:sqlserver://server1:1433","username","password");

///////////////////////////////////

jdbc driver download:

SQLServer:

MySQL:

Oracle:

---------------------DB2--------------------

--------------------- --------------------

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();//For Application

String url = "jdbc:db2:sample";

con = DriverManager.getConnection(url, userid, passwd);

Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();//For Applet

String url = "jdbc:db2:// "+server+":"+port+"/sample";

con = DriverManager.getConnection(url, userid, password );

补充oracle的连接方法:

DriverManager.registerDriver (new OracleDriver());

Connection conn73 = DriverManager.getConnection

("jdbc:oracle:oci8:@ora8idev","scott","tiger");


文章题目:oracle代码怎么写,oracle教程 菜鸟教程
新闻来源:http://cdweb.net/article/dseohig.html