- 浏览: 172902 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
jiasky:
好像是在练书法。
Oracle Function -
blackangel_can:
这样的代码见得多了。
Javascript Print(*) -
tianhendi:
Apache Solr and Tomcat6 Search engine -
laserdance:
我想问下,你怎么从Tomcat等服务器中把上述文件xml准确定 ...
Java parse XML methods(4) -
cskysnew:
第二种如果去掉synchronized,就不是线程安全的,应该 ...
Singlton ture or not?
Oracle encoding format: UTF8
package com.aaron.dao;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public class ConnectCots {
//private final String UID="RCOTRPR1";
//private final String PWD="RCOTRPR1";
private final String UID="RCOTRPR1";
private final String PWD="RCOTRPR1";
private final String DRIVER="oracle.jdbc.driver.OracleDriver";
private final String DBURL = "jdbc:oracle:thin:@192.168.70.54:5201:a3cotr";
private final static String qry="SELECT PAYER_ACC_NO AS EILINE1,PAYER_ACC_NAME AS EILINE2," +
"PAYER_BANK_NAME AS EILINE3,REMARK AS EILINE4 FROM COTS_TAB_DIPS_DETAILS";
public ConnectCots(){
try{
Class.forName(DRIVER);
}catch(ClassNotFoundException e){
System.out.println(e.getMessage());
}
}
public Connection getCon(){
Connection conn=null;
try{
conn=DriverManager.getConnection(DBURL,UID,PWD);
}catch(SQLException e){
System.out.println(e.getMessage());
}
return conn;
}
public void close(Connection con){
if(con!=null){
try{
con.close();
}catch(SQLException e){
System.out.println(e.getMessage());
}
}
}
public ArrayList exeQuery(String sql) throws UnsupportedEncodingException{
ArrayList<String> result=new ArrayList<String>();
Connection connect;
PreparedStatement stmt;
ResultSet rs;
connect=this.getCon();
StringBuffer st=new StringBuffer("");
String filename="d:/aaron.txt";
PrintWriter pw=null;
try {
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF8")),true);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
stmt=connect.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery(sql);
while(rs.next()){
/*
//aaron
//if(rs.getInt(4)>1 && !rs.isFirst()){
if(rs.getInt(4)>1 && rs.previous()){
if( rs.getString(3).startsWith("BIN") ){
rs.next();
break;
}else{
rs.next();
}
}*/
pw.write(rs.getString("EILINE1")); //get the data from db and write to file by UTF8 format
// st.append(new String(rs.getString("EILINE1").getBytes("UTF8"),"GB2312"));
//st.append("|");
// st.append(new String(rs.getString("EILINE2").getBytes("UTF8"),"GB2312"));
// st.append("|");
st.append(rs.getString("EILINE3"));
st.append("|");
st.append(rs.getString("EILINE4"));
//aaron
//String family=rs.getString(1);
//result.add(family);
}
pw.close();
rs.close();
stmt.close();
}catch(SQLException e){
System.out.println(e.getMessage());
}
this.close(connect);
System.out.println(st.toString());
return result;
}
public void getData(String sql){
Connection connect;
PreparedStatement stmt=null;
ResultSet rs=null;
connect=this.getCon();
try{
stmt=connect.prepareStatement(sql);
rs=stmt.executeQuery(sql);
while(rs.next()){
System.out.println(rs.getString("COTS_UID")+"::"+rs.getString("CUSTNUM"));
}
return;
}catch(SQLException e){
System.out.println(e.getMessage());
}
finally{
System.out.println("Enter the finally");
try{
if(rs != null)
rs.close();
if(stmt != null)
stmt.close();
this.close(connect);
} catch (Exception ePstmt) {
System.out.println(" Error in Closing Prepared Statement");
}
System.out.println("End the finally");
}
}
public void sbBuffer(){
StringBuffer sb1=new StringBuffer();
sb1.append("hello");
StringBuffer sb2=sb1;
sb2.append(" World");
System.out.println("SB1:"+sb1.toString());
System.out.print("SB2:"+sb2.toString());
}
public static void main(String[] args) {
ConnectCots aaron =new ConnectCots();
//String test="select ACCT_NUM, length(ACCT_NUM) from COTS_TAB_SWP_KR where to_char(COTS_UPD_DT,'YYYYMMDD')='20070626'";
String test="SELECT BENE.COTS_UID COTS_UID,BENE.CUSTNUM CUSTNUM FROM COTS_TAB_BENE_ADVICE BENE WHERE BRANCH=712 AND DELIVERYSTATUS='FAIL'";
String kk="SELECT BENE.COTS_UID COTS_UID,BENE.BRANCH BRANCH,BENE.CUSTNUM CUSTNUM," +
"BENE.TRANSACTIONREF TRANSACTIONREF,BENE.DELIVERYMEDIA DELIVERYMEDIA," +
"BENE.FILENAME FILENAME,BENE.PAYMENTCCY PAYMENTCCY,BENE.PAYMENTAMT PAYMENTAMT," +
"BENE.ACCTNUM ACCTNUM,SITE.EMAILADR EMAILADR " +
"FROM COTS_TAB_BENE_ADVICE BENE,COTS_TAB_BUSINESS_SITE SITE " +
"WHERE BENE.BRANCH=712 AND BENE.DELIVERYSTATUS='FAIL' " +
"AND BENE.BRANCH=SITE.BRANCH " +
"AND BENE.CUSTNUM=SITE.CUSTNUM " +
"AND SITE.SEQUENCENO=1 " +
"ORDER BY BENE.CUSTNUM";
aaron.getData(kk);
}
}
发表评论
-
移动电商
2016-04-19 18:13 489海外旅行购物电商平台-购轻松,是我们从零开发的App应用,欢迎 ... -
Top 10 Books For Advanced Level Java Developers
2013-11-03 21:59 487Top 10 Books For Advanced Level ... -
RESTful
2013-10-28 22:28 640要使API易用、易于接受和足够灵活,应该遵循以下原则: An ... -
Androd app
2012-08-19 21:35 775an android app -
Jenkins-CI
2012-06-30 08:26 751Jenkins for java and .net CI. -
JNLP
2009-04-20 13:26 1115<?xml version="1.0" ... -
Eclipse3.4 + Axis2 Configuration
2009-03-12 19:53 15641) Download the axis2 v1.4 plug ... -
XML configuration for Spring jsf hibernate
2008-07-16 13:51 1088faces-comfig.xml <?xml ver ... -
Final Usage
2008-04-29 21:05 879final在Java中并不常用,然而它却为我们提供了诸如在C语 ... -
Java tips
2008-03-03 21:39 735// 程序1 class Singleton { priv ... -
Java Connect Pool
2008-02-24 19:13 1929import java.io.*; import java.s ... -
Apache Solr and Tomcat6 Search engine
2008-01-04 13:51 2477Today, test the Solr and Tomcat ... -
Java Multiple process (PID)
2007-12-11 11:29 5899Java的多进程运行模式分析 一般我们在java中运行其它类中 ... -
Glassfish V2 And NetBean6
2007-12-05 16:33 1457Dowload Netbean6 from http://ne ... -
Spring用回调HibernateCallBack方法
2007-11-05 15:45 2888Spring用回调HibernateCallBack方法实现持 ... -
Java中的浅复制与深复制
2007-11-05 13:10 1127Java中的浅复制与深复制 分析一下Java中关于浅复制与深复 ... -
Future pattern
2007-11-04 19:54 2131个人理解 Future 模式就是在主线程中当需要进行比较耗时的 ... -
Log4j Configuration (Recitation)
2007-10-14 20:41 2287一、常用输出格式 %c 列出logger名字空间的全称,如加 ... -
JasperReport usage
2007-09-27 22:07 1158jasperreport tools enhance and ... -
Lucene practice
2007-09-19 22:23 9931.simply practice the lucene ap ...
相关推荐
Learn web scraping and crawling techniques to access unlimited data from any web source in any format. With this practical guide, you’ll learn how to use Python scripts and web APIs to gather and ...
Learn web scraping and crawling techniques to access unlimited data from any web source in any format. With this practical guide, you’ll learn how to use Python scripts and web APIs to gather and ...
A class to dynamically read data from any ODBC data source动态读ODBC数据源的数据
这是一个从txt文件中读取数据的小程序,程序很好理解,编写规范,对初学者有较大帮助。
displaying spatial-temporal displays with Google Earth, and generating code from descriptions of data structures to read and write data. These topics demonstrate the rich possibilities and ...
CODBCDynamic - A class to dynamically read data from any ODBC data source动态从odbc数据源读数据的类
Java解决UTF-8的BOM问题,使用“UnicodeInputStream”、“UnicodeReader”。
Python Data Structures and Algorithms by Benjamin Baka English | 30 May 2017 | ASIN: B01IF7NLM8 | 310 Pages | AZW3 | 6.63 MB Key Features A step by step guide, which will provide you with a thorough...
This read excel data from LabVIEW
clearly show that how the submit and read data
r language read and write data
read_data_from_PhysioNet.m
STM32学习一:那些MDK5的坑,讲解mdk5在开发stm32的时候一些问题和解决方法
《HotR: Alleviating Read/Write Interference with Hot Read Data Replication for Flash Storage》论文的原文及中文翻译。 摘要: 在读写请求混合的工作负载下,闪存的读写干扰问题仍是一个关键问题。为了显著...
The book is a must-read for data scientists, data engineers and information technology leaders who are implementing big data platforms in their organizations. Table of Contents Section I: ...
能够实现从excel表格中读取内容并存储在数组中
How to read datasheet(含原版和翻译版)
Read a csv file into python and R, and print out some statistics on the data. Gain knowledge of the data formats and programming stuctures involved in retrieving API data. Make effective use of ...
Read and Write Utility
数据库 等待事件Db file sequential read...This call differs from a scattered read, because a sequential read is reading data into contiguous memory space. A sequential read is usually a single-block read.