With the help of LiJun I got a piece of JAVA code. With this code, I can do below things like connect to oracle database with jdbc driver and run sql.

Below are the Java code.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
*
* @author xx
*/ public class TestJDBC {
static Connection conn= null;
static String url="jdbc:oracle:thin:@pnd:1521:pnd";
static String username="pnadm";
static String password="password"; public TestJDBC()
{
try{
String driverclass="oracle.jdbc.driver.OracleDriver";
Class.forName(driverclass).newInstance();
conn=DriverManager.getConnection(url,username,password);
}catch(Exception e){
e.printStackTrace();
}
}
public static void getDate(){
String sql="select object_name from all_objects where rownum<2";
try{
Statement stmt=conn.createStatement();
ResultSet rs1=stmt.executeQuery(sql); while(rs1.next()){
System.out.print(rs1.getString("object_name")+" ");
}
}catch(Exception e){
e.printStackTrace();
} } public static void main(String[] args) {
TestJDBC t = new TestJDBC();
for (int i=0;i <30 ; i++)
t.getDate(); try {
Thread.sleep(30000);
} catch (InterruptedException e) {
} for (int i=0;i <280 ; i++)
t.getDate(); try {
Thread.sleep(300000);
} catch (InterruptedException e) {
} }
}

There is something important I need to record down.

1. You need to specify classpath environment variable for example

export CLASS_PATH=/opt/oracle/product/10.2/jdbc/lib/ojdbc14.jar

2. You can get the jdbc driver from oracle directory

最新文章

  1. 编译安装zabbix3.2
  2. 回头再看N层架构(图解)
  3. LVS+MYCAT读写分离+MYSQL同步部署手册(第三版)
  4. IIS7.5
  5. JavaScript深入浅出1-数据类型
  6. matlab批量合并txt文件
  7. java入门第二步之helloworld【转】
  8. postgresql cast转换类型
  9. cocos2dx使用tolua关于字符串处理的一个问题
  10. 查看TOMCAT内存使用情况 以及修改方法
  11. 一.redis 环境搭建
  12. JavaScript Boolean(布尔)对象
  13. JAVA设计模式--学习总结(序)
  14. iOS------自动查找项目中不用的图片资源
  15. Spring扫面路径配置不全导致异常 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 的原因
  16. import、export 和export default區別
  17. WebLogic Server Components:XA Transactions
  18. Java序列化的作用和反序列化
  19. C#打印0到100的素数
  20. 知识点【JavaScript模块化】

热门文章

  1. [Swift通天遁地]三、手势与图表-(8)制作股市中常用的蜡烛图表
  2. Java线程之Synchronized用法
  3. skiing 暴力搜索 + 动态规划
  4. 题解报告:hdu 1575 Tr A
  5. JSP所需要掌握的部分
  6. Linux命令(002) -- free
  7. C++ friend关键字
  8. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;empid&#39; in &#39;class cn.happy.entity.Emp&#39;
  9. C++ Primer(第4版)-学习笔记-第2部分:容器和算法
  10. mysql中返回当前时间的函数或者常量