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(
相关文档:
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 ......
Mysql
sudo netstat -tap | grep mysql
当您运行该命令时,您可以看到类似下面的行:
linuxidc@linuxidc-laptop:~$">linuxidc@linuxidc-laptop:~$ sudo netstat -tap | grep mysql
[sudo] password for linuxidc:
tcp &n ......
一.获得控制台用户输入的信息
Java代码
/** */
/**获得控制台用户输入的信息
* @return
* @throws IOException
*/
public
  ......
/**
* 获得当前时间一小时前的时间,格式化成yyyy-MM-dd HH:mm:ss:SS<br>
*
* @return 当前时间一小时前的时间
*/
public String getOneHours ......