oracle连接数据库测试代码
oracle连接数据库测试代码
/**
*
* 说明:
* (1)本例使用JDBC_ODBC桥进行数据库连接,故此需要ODBC数据源
* (2)本例中SQL为更新语句,故此使用载体的executeUpdate方法,并且返回受影响记录数
* (3) 配置连接ORACLE的odbc数据源ora
*/
//导入所需类包
import java.sql.*;
public class JdbcTestOra2 {
public static void main(String args[]) {
try {
//装载驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//建立数据库连接
Connection con =
DriverManager.getConnection("jdbc:odbc:ora","scott","tiger");
//创建SQL语句载体
Statement st = con.createStatement();
//执行SQL语句,接收执行结果
int rs = st.executeUpdate("update emp set
comm=1000");
//处理结果
System.out.println("修改记录数:"+rs);
//释放数据库资源,注意顺序
st.close();
con.close();
}
catch (Exception e) {
e.printStackTrace(System
相关文档:
输入参数:str ——要截取的字符串, ch——要查找的字符串
截取ch之前(不包括ch)的字符串: substr(str, 0, instr(str, ch) - 1)
截取ch之后(不包括ch)的字符串: substr(str, , instr(str, ch) + 1, length(str)) ......
一、 常用日期数据格式
1.Y或YY或YYY 年的最后一位,两位或三位
SQL> Select to_char(sysdate,'Y') from dual;
TO_CHAR(SYSDATE,'Y')
--------------------
7
SQL> Select to_char(sysdate,'YY') from dual;
TO_CHAR(SYSDATE,'YY')
---------------------
07
SQL> Select to_char(sysdate,'YYY') from ......
linux 上的oracle sqlplus 不能利用 上, 下 键来查看命令,搜索到解决问题的办法,整理如下
安装软件rlwrap可以解决这个问题,该软件是用c写的程序
官方下载地址:http://utopia.knoware.nl/~hlub/uck/rlwrap/
安装过程:
我们也可以查看解压后的tar包,查看README帮助文件
shell>tar -zxvf rlwrap-0.36.tar.gz
sh ......
Wait Problem Potential Fix Sequential Read Indicates many index reads—tune the code (especially joins) Scattered Read Indicates many full table scans—tune the code; cache small tables ......