- 浏览: 128591 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (165)
- 数据库 (45)
- 架构 (0)
- java web前端+框架 (9)
- java web后端+框架 (56)
- Eclipse插件 (1)
- 解题思路 (2)
- Eclipse (2)
- linux (6)
- jquery (4)
- 正则 (3)
- jsp (1)
- javascript (8)
- oracle (39)
- 生活 (1)
- weblogic (5)
- tomcat (3)
- Jrebel (1)
- powerdesigner (1)
- svn (1)
- log4j (1)
- IDE (1)
- POI (2)
- jvm (2)
- ssh (1)
- http (1)
- notepad++ (2)
- 润乾 (1)
- 设计模式 (0)
- 实用类Utils (2)
- 算法 (1)
- xml (1)
- 实用类 (2)
最新评论
package com.achievo.ems.web.service.score;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConnUtils2 {
public static Logger logger = LoggerFactory.getLogger(ConnUtils2.class);
private final static String DRIVER_1 = "oracle.jdbc.driver.OracleDriver";
private final static String URL_1 = "jdbc:oracle:thin:@10.5.117.28:1521:orcl";
private final static String USERNAME_1 = "emis";
private final static String PASSWORD_1 = "emis";
private final static String DRIVER_2 = "oracle.jdbc.driver.OracleDriver";
private final static String URL_2 = "jdbc:oracle:thin:@10.5.119.132:1521:kaowu";
private final static String USERNAME_2 = "ems";
private final static String PASSWORD_2 = "emis2013";
public static Connection getConnect_1() {
Connection conn = null;
try {
Class.forName(DRIVER_1).newInstance();
conn = DriverManager.getConnection(URL_1, USERNAME_1, PASSWORD_1);
} catch (Exception e) {
throw new RuntimeException("获取连接失败", e);
}
return conn;
}
public static Connection getConnect_2() {
Connection conn = null;
try {
Class.forName(DRIVER_2).newInstance();
conn = DriverManager.getConnection(URL_2, USERNAME_2, PASSWORD_2);
} catch (Exception e) {
throw new RuntimeException("获取连接失败", e);
}
return conn;
}
public static void main(String[] args) throws Throwable {
ConnUtils2 connUtils = new ConnUtils2();
connUtils.testEncrypt(1);
// AtomicInteger ai = new AtomicInteger(10);
//
// while (ai.get() > 0) {
// int intValue = ai.getAndDecrement();
// System.out.println(intValue);
// }
}
/**
* 加签测试
*
* @param whichDb
* @throws Throwable
*/
public void testEncrypt(int whichDb) throws Throwable {
Connection conn = null;
if (1 == whichDb) {
conn = ConnUtils2.getConnect_1();
} else {
conn = ConnUtils2.getConnect_2();
}
String sql = " select SCORE_ID as scoreId "//
+ " ,ID as csubjId "//
+ " ,EXAMINEE_ID as creditId "//
+ " ,SUBJECTIVE_RESULT as score "//
+ " ,FLAG as flag "//
+ " ,exception as exceptionFlag "//
+ " ,SIGNATURE as signature "//
+ " ,CREATE_TIME as createTime "//
+ " ,UPDATE_TIME as updateTime "//
+ " ,CREATE_BY as createBy "//
+ " ,UPDATE_BY as updateBy "//
+ " ,APPLY_NO as applyNo "//
+ " from P_SUBJECTIVE_SCORE_ORIG_VERNON "//
;
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData md = rs.getMetaData();
int columnCount = md.getColumnCount();
List<String> columnNameList = new ArrayList<String>();
for (int i = 1; i <= columnCount; i++) {
String columnName = md.getColumnName(i);
columnNameList.add(columnName);
}
List<PSubjectiveScoreOrigVernon> pssoList = new ArrayList<PSubjectiveScoreOrigVernon>();
while (rs.next()) {
PSubjectiveScoreOrigVernon psso = new PSubjectiveScoreOrigVernon();
for (String columnLabel : columnNameList) {
String value = rs.getString(columnLabel);
BeanUtils.setProperty(psso, columnLabel, value);
}
pssoList.add(psso);
}
try {
EncryptDecryptTask4Test.getInstance().encrypt(pssoList);
if (logger.isDebugEnabled()) {
logger.debug("加签成功");
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("加签失败");
}
}
for (int i = 0; i < 10; i++) {
if (logger.isDebugEnabled()) {
PSubjectiveScoreOrigVernon psso = pssoList.get(i);
logger.debug(psso.getEncryptedInfo());
}
}
for (int i = pssoList.size() - 10; i < pssoList.size(); i++) {
if (logger.isDebugEnabled()) {
PSubjectiveScoreOrigVernon psso = pssoList.get(i);
logger.debug(psso.getEncryptedInfo());
}
}
try {
EncryptDecryptTask4Test.getInstance().decrypt(pssoList);
if (logger.isDebugEnabled()) {
logger.debug("验签成功");
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("验签失败");
}
}
}
@SuppressWarnings("unused")
private void encryptByMultiThreads(List<PSubjectiveScoreOrigVernon> pssoList) {
long begin_4_multi_threads = System.currentTimeMillis();
System.out.println("多线程加签---开始=" + begin_4_multi_threads);
EncryptDecryptTask4Test.getInstance().encrypt(pssoList);
long end_4_multi_threads = System.currentTimeMillis();
System.out.println("多线程加签---结束=" + end_4_multi_threads);
long ms_4_multi_threads = (end_4_multi_threads - begin_4_multi_threads);
System.out.println("多线程加签花费毫秒数=" + ms_4_multi_threads);
String ms2Hms_4_multi_threads = ConnUtils2.ms2Hms(ms_4_multi_threads);
System.out.println("多线程加签共耗时共耗时:" + ms2Hms_4_multi_threads);
}
@SuppressWarnings("unused")
private void encryptBySingleThreads(List<PSubjectiveScoreOrigVernon> pssoList) {
long begin_4_single_threads = System.currentTimeMillis();
System.out.println("单线程加签---开始=" + begin_4_single_threads);
EncryptDecryptUtils4Test5.encrypt(pssoList);
long end_4_single_threads = System.currentTimeMillis();
System.out.println("单线程加签---结束=" + end_4_single_threads);
long ms_4_single_threads = (end_4_single_threads - begin_4_single_threads);
System.out.println("单线程加签花费毫秒数=" + ms_4_single_threads);
String ms2Hms_4_single_threads = ConnUtils2.ms2Hms(ms_4_single_threads);
System.out.println("单线程加签共耗时:" + ms2Hms_4_single_threads);
}
// oracle.sql.Clob类型转换成String类型
public static String clobToString(Clob clob) {
String reString = "";
Reader is = null;
try {
is = clob.getCharacterStream();
} catch (SQLException e) {
e.printStackTrace();
}
// 得到流
BufferedReader br = new BufferedReader(is);
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
StringBuffer sb = new StringBuffer();
while (s != null) {
// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
sb.append(s);
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
}
reString = sb.toString();
return reString;
}
public static String ms2Hms(long ms) {
// 毫秒 秒 分 时
long hour = ms / 1000 / 60 / 60;
// 毫秒 秒 分
long min = ms / 1000 / 60 % 60;
// 毫秒 秒
long sec = ms / 1000 % 60;
// 毫秒 秒
long mi = ms % 1000;
java.lang.String x = hour + "时" + min + "分" + sec + "秒" + mi + "毫秒";
// java.lang.String x = hour + "H" + min + "M" + sec + "S" + mi + "MS";
return x;
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConnUtils2 {
public static Logger logger = LoggerFactory.getLogger(ConnUtils2.class);
private final static String DRIVER_1 = "oracle.jdbc.driver.OracleDriver";
private final static String URL_1 = "jdbc:oracle:thin:@10.5.117.28:1521:orcl";
private final static String USERNAME_1 = "emis";
private final static String PASSWORD_1 = "emis";
private final static String DRIVER_2 = "oracle.jdbc.driver.OracleDriver";
private final static String URL_2 = "jdbc:oracle:thin:@10.5.119.132:1521:kaowu";
private final static String USERNAME_2 = "ems";
private final static String PASSWORD_2 = "emis2013";
public static Connection getConnect_1() {
Connection conn = null;
try {
Class.forName(DRIVER_1).newInstance();
conn = DriverManager.getConnection(URL_1, USERNAME_1, PASSWORD_1);
} catch (Exception e) {
throw new RuntimeException("获取连接失败", e);
}
return conn;
}
public static Connection getConnect_2() {
Connection conn = null;
try {
Class.forName(DRIVER_2).newInstance();
conn = DriverManager.getConnection(URL_2, USERNAME_2, PASSWORD_2);
} catch (Exception e) {
throw new RuntimeException("获取连接失败", e);
}
return conn;
}
public static void main(String[] args) throws Throwable {
ConnUtils2 connUtils = new ConnUtils2();
connUtils.testEncrypt(1);
// AtomicInteger ai = new AtomicInteger(10);
//
// while (ai.get() > 0) {
// int intValue = ai.getAndDecrement();
// System.out.println(intValue);
// }
}
/**
* 加签测试
*
* @param whichDb
* @throws Throwable
*/
public void testEncrypt(int whichDb) throws Throwable {
Connection conn = null;
if (1 == whichDb) {
conn = ConnUtils2.getConnect_1();
} else {
conn = ConnUtils2.getConnect_2();
}
String sql = " select SCORE_ID as scoreId "//
+ " ,ID as csubjId "//
+ " ,EXAMINEE_ID as creditId "//
+ " ,SUBJECTIVE_RESULT as score "//
+ " ,FLAG as flag "//
+ " ,exception as exceptionFlag "//
+ " ,SIGNATURE as signature "//
+ " ,CREATE_TIME as createTime "//
+ " ,UPDATE_TIME as updateTime "//
+ " ,CREATE_BY as createBy "//
+ " ,UPDATE_BY as updateBy "//
+ " ,APPLY_NO as applyNo "//
+ " from P_SUBJECTIVE_SCORE_ORIG_VERNON "//
;
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData md = rs.getMetaData();
int columnCount = md.getColumnCount();
List<String> columnNameList = new ArrayList<String>();
for (int i = 1; i <= columnCount; i++) {
String columnName = md.getColumnName(i);
columnNameList.add(columnName);
}
List<PSubjectiveScoreOrigVernon> pssoList = new ArrayList<PSubjectiveScoreOrigVernon>();
while (rs.next()) {
PSubjectiveScoreOrigVernon psso = new PSubjectiveScoreOrigVernon();
for (String columnLabel : columnNameList) {
String value = rs.getString(columnLabel);
BeanUtils.setProperty(psso, columnLabel, value);
}
pssoList.add(psso);
}
try {
EncryptDecryptTask4Test.getInstance().encrypt(pssoList);
if (logger.isDebugEnabled()) {
logger.debug("加签成功");
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("加签失败");
}
}
for (int i = 0; i < 10; i++) {
if (logger.isDebugEnabled()) {
PSubjectiveScoreOrigVernon psso = pssoList.get(i);
logger.debug(psso.getEncryptedInfo());
}
}
for (int i = pssoList.size() - 10; i < pssoList.size(); i++) {
if (logger.isDebugEnabled()) {
PSubjectiveScoreOrigVernon psso = pssoList.get(i);
logger.debug(psso.getEncryptedInfo());
}
}
try {
EncryptDecryptTask4Test.getInstance().decrypt(pssoList);
if (logger.isDebugEnabled()) {
logger.debug("验签成功");
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("验签失败");
}
}
}
@SuppressWarnings("unused")
private void encryptByMultiThreads(List<PSubjectiveScoreOrigVernon> pssoList) {
long begin_4_multi_threads = System.currentTimeMillis();
System.out.println("多线程加签---开始=" + begin_4_multi_threads);
EncryptDecryptTask4Test.getInstance().encrypt(pssoList);
long end_4_multi_threads = System.currentTimeMillis();
System.out.println("多线程加签---结束=" + end_4_multi_threads);
long ms_4_multi_threads = (end_4_multi_threads - begin_4_multi_threads);
System.out.println("多线程加签花费毫秒数=" + ms_4_multi_threads);
String ms2Hms_4_multi_threads = ConnUtils2.ms2Hms(ms_4_multi_threads);
System.out.println("多线程加签共耗时共耗时:" + ms2Hms_4_multi_threads);
}
@SuppressWarnings("unused")
private void encryptBySingleThreads(List<PSubjectiveScoreOrigVernon> pssoList) {
long begin_4_single_threads = System.currentTimeMillis();
System.out.println("单线程加签---开始=" + begin_4_single_threads);
EncryptDecryptUtils4Test5.encrypt(pssoList);
long end_4_single_threads = System.currentTimeMillis();
System.out.println("单线程加签---结束=" + end_4_single_threads);
long ms_4_single_threads = (end_4_single_threads - begin_4_single_threads);
System.out.println("单线程加签花费毫秒数=" + ms_4_single_threads);
String ms2Hms_4_single_threads = ConnUtils2.ms2Hms(ms_4_single_threads);
System.out.println("单线程加签共耗时:" + ms2Hms_4_single_threads);
}
// oracle.sql.Clob类型转换成String类型
public static String clobToString(Clob clob) {
String reString = "";
Reader is = null;
try {
is = clob.getCharacterStream();
} catch (SQLException e) {
e.printStackTrace();
}
// 得到流
BufferedReader br = new BufferedReader(is);
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
StringBuffer sb = new StringBuffer();
while (s != null) {
// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
sb.append(s);
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
}
reString = sb.toString();
return reString;
}
public static String ms2Hms(long ms) {
// 毫秒 秒 分 时
long hour = ms / 1000 / 60 / 60;
// 毫秒 秒 分
long min = ms / 1000 / 60 % 60;
// 毫秒 秒
long sec = ms / 1000 % 60;
// 毫秒 秒
long mi = ms % 1000;
java.lang.String x = hour + "时" + min + "分" + sec + "秒" + mi + "毫秒";
// java.lang.String x = hour + "H" + min + "M" + sec + "S" + mi + "MS";
return x;
}
}
发表评论
-
eclipse java代码格式化 javaformatter20150123.zip
2015-01-23 11:30 705eclipse java代码格式化 javaformatter ... -
List to Map
2015-01-21 17:22 477/** * <p>将List变为Map</p ... -
读取access工具类-ReadAccessUtil2
2015-01-06 13:52 546import com.healthmarketscience. ... -
ParameterizedType获取java泛型参数类型
2014-11-14 15:15 696ParameterizedType获取java泛型参数类型 ... -
分页帮助类-oracle-java
2014-10-09 17:46 456/** * 分页帮助类 * * @author ver ... -
java自动实例化List AutoArrayList
2014-07-21 15:51 733import java.util.ArrayList; p ... -
单一登录过滤器
2014-06-20 17:13 394/** * 单一登录过滤器 * * @author v ... -
正则 java 查找 打印 所有匹配项
2014-06-18 11:26 634package com.test.regex; import ... -
第3方包读取Access
2014-05-26 16:07 659package com.test; import java. ... -
多线程加签验签例子.zip
2014-05-26 16:08 508多线程加签验签例子.zip -
DateTimeUtils
2014-05-26 16:08 644import java.text.DateFormat; im ... -
listToMap
2014-05-26 16:09 434/** * List实用类 * * @author v ... -
JdbcTemplateRowMapper
2015-05-19 15:44 572import java.lang.reflect.Constr ... -
KeyValuePair2
2015-05-19 15:44 504/** * 键值对 * * @author verno ... -
OrderUtil -排序工具
2014-05-22 09:35 649/** * 排序工具 * * @author vern ... -
ZipUtils
2014-05-22 09:35 441import java.io.BufferedOutputSt ... -
TimerUtils
2014-05-22 09:34 474import org.slf4j.Logger; import ... -
Excel View 4 Spring
2014-05-22 09:29 335Excel View 4 Spring @RequestMa ... -
DOMUtils xml操作实用类
2014-04-07 21:41 801/* * Copyright 2001-2004 The A ... -
生成验证码 数学+字母
2014-04-01 10:08 435public static String getCharAnd ...
相关推荐
这种情况下,如果应用程序代码直接尝试将 `weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB` 转换成 `oracle.sql.CLOB`,则会抛出类型转换异常。为了解决这一问题,我们需要采用一种方法来安全地实现这两种类型的相互...
### ORACLE中CLOB字段转String类型 在Oracle数据库中,`CLOB`(Character Large Object)是一种用于存储大量文本数据的数据类型。由于其能够存储非常大的文本块(最大可达4GB),因此常被用于存储文章、报告或任何...
Oracle.ManagedDataAccess.dll是Oracle公司为.NET开发者提供的一个托管数据访问组件,它允许C#等.NET语言的应用程序直接与Oracle数据库进行交互,无需依赖传统的Oracle客户端软件。这个RAR压缩包包含了两个不同版本...
### 运用Java如何存取Oracle中的CLOB类型字段 #### 概述 在数据库操作中,经常会遇到处理大量文本数据的需求,例如存储文章、新闻、文档等。Oracle数据库提供了CLOB(Character Large Object)类型来存储大容量的...
SQL Server 中 Image 类型数据导出到 Oracle 的 CLOB 字段中 在进行数据库迁移或数据交换时,需要将不同数据库管理系统之间的数据类型进行转换。在本文中,我们将讨论如何将 SQL Server 中的 Image 类型数据导出到 ...
在处理CLOB类型时,MyBatis需要将Java对象中的String或Reader类型数据转换为CLOB,以便存储到数据库中。 1. **CLOB类型数据的插入** 当你需要将一个字符串或者Reader对象插入到CLOB字段时,MyBatis默认可能无法...
Oracle 数据类型 CHAR 对应的 JDBC 类型是 java.sql.Types.CHAR,Java 类型是 java.lang.String。VARCHAR2 对应的 JDBC 类型是 java.sql.Types.VARCHAR,Java 类型也是 java.lang.String。LONG 对应的 JDBC 类型是 ...
`UTL_RAW.CAST_TO_VARCHAR2`是Oracle提供的一个包中的函数,用于将RAW或BLOB类型的二进制数据转换为VARCHAR2字符串类型。这一步骤对于将BLOB转换为CLOB至关重要,因为CLOB本质上是一种字符数据类型,而不能直接与二...
标题中的“jdbc连接例子 Oracle CLOB转换为String java调用存储过程之输出游标”涉及到三个主要的Java数据库编程知识点:JDBC连接、Oracle数据库中的CLOB类型处理以及通过Java调用存储过程处理输出游标。 1. JDBC...
4. **高级特性支持**:包括PL/SQL块执行、游标、事务控制、批处理操作、存储过程调用、Oracle特定的数据类型(如BFILE、CLOB、NCLOB等)以及XML处理。 5. **安全性**:提供身份验证、授权和加密功能,确保数据的...
此外,ODP.NET还支持处理复杂的Oracle特性,如PL/SQL、游标、BLOB/CLOB数据类型、触发器和存储过程。 总之,Oracle.ManagedDataAccess是C#与Oracle数据库集成的关键组件,通过这个驱动,开发者能够轻松地在.NET应用...
4. 支持Oracle特性:包括Oracle特定的数据类型(如BLOB、CLOB、NCLOB、XMLType等)、游标、触发器、PL/SQL块等。此外,它还支持Oracle高级安全特性,如角色、权限、加密等。 5. 集成开发环境支持:Oracle.Data...
在Java编程中,为了能够有效地与Oracle数据库中的CLOB类型交互,Java提供了`java.sql.Clob`类作为接口。 **1. CLOB的读取方法** - **getCharacterStream()**:返回一个`java.io.Reader`对象,按照Unicode编码读取...
此时,将CLOB转换为VARCHAR2等类型可以提高查询速度。 2. **数据展示**:为了便于前端展示,有时需要将CLOB类型的数据转换为更适合网页显示的格式。 3. **数据迁移**:在进行数据库迁移或重构时,可能需要将原有...
在Oracle数据库中,CLOB(Character Large Object)是一种用于存储大量文本数据的数据类型,如XML文档、长篇文章或任何其他非二进制的大型数据。本文将深入探讨Oracle中的CLOB类型文字处理,以及如何在实际操作中...
CLOB操作与BLOB操作类似,但是在获取java.sql.Clob对象后需要强制转换为oracle.sql.CLOB对象,以便使用getCharacterOutputStream()方法将数据写入CLOB字段。 三、出库操作 出库操作可以使用ResultSet.getBlob()或...
2. **创建参数数组**:创建一个`OracleParameter`数组,其中包含一个类型为`OracleType.Clob`的参数,该参数将在执行时绑定到SQL语句中的CLOB字段。 3. **设置参数值**:将要插入的CLOB数据赋值给参数`lgContent`。 ...
- `VARCHAR2`:Oracle 中的变长字符串类型,映射为 `java.lang.String`。 - `CHAR` 和 `VARCHAR`:这两个 SQL 标准的字符串类型在 Oracle 中也有相应映射。 - `CLOB`:用于存储大量文本数据,映射为 `oracle.sql....