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

A java code的更多相关文章

  1. Java语言编码规范(Java Code Conventions)

    Java语言编码规范(Java Code Conventions) 名称 Java语言编码规范(Java Code Conventions) 译者 晨光(Morning) 简介 本文档讲述了Java语 ...

  2. java code to byte code--partone--reference

    Understanding how Java code is compiled into byte code and executed on a Java Virtual Machine (JVM) ...

  3. [转]Java Code Examples for android.util.JsonReader

    [转]Java Code Examples for android.util.JsonReader The following are top voted examples for showing h ...

  4. SQL to Java code for Elasticsearch

    Elasticsearch虽然定位为Search Engine,但是因其可以持久化数据,很多时候,我们把Elasticsearch当成Database用,但是Elasticsearch不支持SQL,就 ...

  5. JUnit单元测试教程(翻译自Java Code Geeks)

    JUnit单元测试教程--终极指南 JUnit单元测试教程终极指南 说明 单元测试简介 1 什么是单元测试 2 测试覆盖 3 Java中的单元测试 JUnit简介 1 使用Eclipse实现简单JUn ...

  6. Java Code Style

    近期困惑于团队成员代码风格迥异,代码质量不可控,作为一名老司机,忧患于后期服务的可维护性,多次一对一的代码Review,耗时耗力不说,效果也不明显.痛定思痛,多次反思之后得出结论:无规矩不成方圆,可靠 ...

  7. 玩转Eclipse — 自动代码生成的Java Code Template

    文章转载地址:点击打开链接 当代码写到一定程度之后,就会发现很多代码都被重复地敲了N多遍,甚至毫不夸张地说:闭着眼睛都能敲出来.大量地敲这些重复地代码,除了锻炼敲键盘的速度,基本上没有其他益处,但是长 ...

  8. Use formatter to format your JAVA code

    In order to make the codes looks unified and make it easy to understand, it's better to use the same ...

  9. 【Android XML】Android XML 转 Java Code 系列之 介绍(1)

    最近在公司做一个项目,需要把Android界面打包进jar包给客户使用.对绝大部分开发者来说,Android界面的布局以XML文件为主,并辅以少量Java代码进行动态调整.而打包进jar包的代码,意味 ...

  10. 在IntelliJ IDEA中配置Google Java Code Style及代码格式化快捷键

    google-java-format plugin should intercept the “Reformat Code” action in IDEA (Ctrl+Alt+L) and apply ...

随机推荐

  1. [NOI1999] 棋盘分割(推式子+dp)

    http://poj.org/problem?id=1191 棋盘分割 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 156 ...

  2. Linux 下文本查找技巧你掌握了吗?

    前言 之前介绍过很多linux下查找相关的命令,例如<Linux中的文件查找技巧>,<find命令高级用法>,<如何查看linux中文件打开情况-lsof命令>等等 ...

  3. Java转大数据开发全套视频资料

    大数据在近两年可算是特别火,有很多人都想去学大数据,有java转大数据的,零基础学习大数据的.但是大数据真的好学吗. 我们先来了解一下什么是大数据. 大数据是指无法在一定时间内用常规软件工具对其内容进 ...

  4. 动态规划DP入门

    百度百科↓ 动态规划(dynamic programming)是运筹学的一个分支,是求解决策过程(decision process)最优化的数学方法.20世纪50年代初美国数学家R.E.Bellman ...

  5. MFC学习篇(二):error LNK2005 及其解决方法

    环境:MFC条件下添加原有代码 >nafxcwd.lib(afxmem.obj) : error LNK2005: @YAPAXI@Z) already defined in LIBCMTD.l ...

  6. Educational Codeforces Round 45

    A. 一个小模拟    不解释 //By SiriusRen #include <bits/stdc++.h> using namespace std; long long n,m,a,b ...

  7. Centos7基本命令

    shell基本命令 linux命令行的组成结构 linux系统命令操作语法格式 命令 空格 参数 空格 文件路径或者需要处理的内容 rm   -rf   /tmp/* ls   -la   /home ...

  8. C#中的分层开发

    一般来说,分层主要分三层即:UI(User Interface) 界面显示层,BLL(Business Logic Layer)业务逻辑层,以及DAL(Data Access Layer)数据访问层. ...

  9. Android 使用WebView浏览有声音或者视频的网页,关闭WebView之后,声音或者视频不停止的解决办法

    笔者最近使用Eclipse开发Android移动应用app,其实有一个功能是使用Android系统自带的WebView控件加载Web页面.开发很顺利,浏览也很正常.不过有个比较特殊的一点就是加载的We ...

  10. Discuz 取消 应用更新提醒 方法

    管理员每次登录论坛,遇有后台没有更新的应用都会有应用更新提醒提醒,而且关了还会继续弹出,问题是有些应用原来我装了免费的,新版本推出来了是 要收费的,我不想要更新,或者是即使有免费的新版本了,而我只要使 ...