易截截图软件、单文件、免安装、纯绿色、仅160KB

java操作oracle数据库

 package com.chinacache.boss.queryservice.service.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.chinacache.boss.queryservice.exception.BusinessException;
import oracle.sql.ArrayDescriptor;
public class Main {
public static void main(String[] args) throws Exception {
Connection conn = null;
PreparedStatement pstmt = null;
java.sql.Array sqlArray = null;
conn = getOracleConnection();
// For oracle you need an array descriptor specifying
// the type of the array and a connection to the database
// the first parameter must match with the SQL ARRAY type created
ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
"CHAR_ARRAY", conn);// CREATE OR REPLACE TYPE CHAR_ARRAY AS table OF VARCHAR2(255)
// then obtain an Array filled with the content below
String[] content = { "5137", "V2", "V3", "V4" };
sqlArray = new oracle.sql.ARRAY(arrayDescriptor, conn, content);
pstmt = conn.prepareStatement(""
+ "select * "
+ "from bandwith_area_test t where t.channel_id in (select * from the (select cast(? as CHAR_ARRAY) from dual)) and t.area_id = ?" + "and t.day >= ? and t.day <= ? order by t.day");
Date start = null;
Date end = null;

try {
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm");
start = df.parse("200907011000");
end = df.parse("200907012000");
} catch (ParseException e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
}

pstmt.setArray(1, sqlArray);
pstmt.setString(2, "9050");
pstmt.setDate(3, new java.sql.Date(start.getTime()));
pstmt.setDate(4, new java.sql.Date(end.getTime()));
int rowCount = pstmt.executeUpdate();
System.out.println("rowCount=" + rowCount);
System.out.println("--Demo_PreparedStatement_SetArray end--");
pstmt.close(


相关文档:

oracle 表空间操作

oracle表空间操作详解
  1
  2
  3作者:   来源:    更新日期:2006-01-04 
  5
  6 
  7建立表空间
  8
  9CREATE TABLESPACE data01
 10DATAFILE '/ora ......

Sun Java Wireless Toolkit 2.3 beta新增功能


原文出处:http://developers.sun.com/techtopics/mobility/midp/articles/wtk23beta/
 
       Sun Java Wireless Toolkit越来越好,2.3beta版本增加了对于三种新的API的支持:
l         The Security and Trust Services APIs (SATSA, ......

java开源类库pinyin4j的使用

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import net.sourceforge.pinyin4j.PinyinHelper;
public class PinyinComparator implements Comparator<Object> {
    private String concatPinyinStringArray(String[] pinyinArray) {
   &nb ......

Java Filter 过滤器的使用

1、建立一个Servlet并且实现Filter接口
该类需要实现Filter接口中的init()   doFilter()    destory()方法
其中init()方法自动在项目启动的时候加载,doFilter()在调用xml配置的路径是加载,destory()方法在退出项目的时候进行。
 
public class TestFilter implements Filter{
  ......

java获得当前时间一小时前的时间,格式化成yyyy

       /**
     * 获得当前时间一小时前的时间,格式化成yyyy-MM-dd HH:mm:ss:SS<br>
     *
     * @return 当前时间一小时前的时间
     */
    public String getOneHours ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号