如何在linux环境下调试JAVA程序使用访问timesten:

简介:

 

一.如何在linux环境下调试JAVA程序使用访问timesten:

1.配置jdk环境变量:

上传jdk-6u7-linux-i586.bin文件到/data0/目录下,执行如下命令: 
[root@ora11gr2 data0]#chmod 777 jdk-6u7-linux-i586.bin 
[root@ora11gr2 data0]#./jdk-6u7-linux-i586.bin 
[root@ora11gr2 data0]# ln -sn /data0/jdk1.6.0_07/ /usr/java 前面为源,后面为目的 
[root@ora11gr2 data0]# vim /etc/profile 
在文件最后,添加如下三行: 
export JAVA_HOME=/data0/jdk1.6.0_07 
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib 
export PATH=/usr/java/bin:$PATH

[root@ora11gr2 data0]# source /etc/profile

timesten用户环境变量文件~/.bash_profile下添加如下几行: 
[timesten@ora11gr2 ~]$ vim ~/.bash_profile 
#add timsten env 
export ORACLE_SID=mytest 
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK 
export ORACLE_HOME=/app/oracle/product/11.2.0/db_1 
export TT_HOME=/data0/timesten/TimesTen/tt1122 
export TNS_ADMIN=/app/oracle/product/11.2.0/db_1/network/admin 
export CLASSPATH=/data0/timesten/TimesTen/tt1122/lib/ttjdbc5.jar:/app/oracle/product/11.2.0/db_1/jdbc/lib/ojdbc5.jar:$CLASSPATH 
export PATH=/data0/timesten/TimesTen/tt1122/bin/:$ORACLE_HOME/bin:$PATH 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:$ORACLE_HOME/network/lib:/data0/timesten/TimesTen/tt1122/lib:$LD_LIBRARY_PATH

[timesten@ora11gr2 ~]$ javac 
Usage: javac <options> <source files> 
where possible options include: 
-g Generate all debugging info 
-g:none Generate no debugging info 
-g:{lines,vars,source} Generate only some debugging info 
-nowarn Generate no warnings 
-verbose Output messages about what the compiler is doing 
-deprecation Output source locations where deprecated APIs are used 
-classpath <path> Specify where to find user class files and annotation processors 
-cp <path> Specify where to find user class files and annotation processors 
-sourcepath <path> Specify where to find input source files 
-bootclasspath <path> Override location of bootstrap class files 
-extdirs <dirs> Override location of installed extensions 
-endorseddirs <dirs> Override location of endorsed standards path 
-proc:{none,only} Control whether annotation processing and/or compilation is done. 
-processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process 
-processorpath <path> Specify where to find annotation processors 
-d <directory> Specify where to place generated class files 
-s <directory> Specify where to place generated source files 
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files 
-encoding <encoding> Specify character encoding used by source files 
-source <release> Provide source compatibility with specified release 
-target <release> Generate class files for specific VM version 
-version Version information 
-help Print a synopsis of standard options 
-Akey[=value] Options to pass to annotation processors 
-X Print a synopsis of nonstandard options 
-J<flag> Pass <flag> directly to the runtime system

[timesten@ora11gr2 ~]$ javac -version 
javac 1.6.0_07

2.编写JAVA测试代码:

[timesten@ora11gr2 ~]$ cat TTtest.java 
import java.sql.*; 
import javax.sql.*; 
public class TTtest{ 
public static void main(String args[]) 

//String URL = "jdbc:timesten:client:dsn=lujgCS_1122"; Remote Connect Strings 
String URL = "jdbc:timesten:direct:dsn=lujg_1122";

Connection con = null; 
try { 
Class.forName("com.timesten.jdbc.TimesTenDriver"); 

catch (ClassNotFoundException ex) 
{ex.printStackTrace(); 

try { 
con = DriverManager.getConnection(URL); 
System.out.println("connected"); 
java.sql.Statement st=con.createStatement(); 
java.sql.ResultSet rs=st.executeQuery("select * from test"); 
while (rs.next()) 

System.out.println(rs.getString("id")); 
}

con.close(); 
} catch (SQLException ex) { 
ex.printStackTrace();} 

}

编译程序:

[timesten@ora11gr2 ~]$ javac TTtest.java 
[timesten@ora11gr2 ~]$ ll 
-rw-r--r-- 1 timesten oinstall 1395 Mar 8 10:13 TTtest.class 
-rwxr-xr-x 1 timesten oinstall 715 Mar 8 10:13 TTtest.java

查看执行结果:

[timesten@ora11gr2 ~]$ java TTtest 
connected 
100 
200 
300

 

 

     本文转自vcdog 51CTO博客,原文链接:http://blog.51cto.com/255361/838318,如需转载请自行联系原作者


相关文章
|
4天前
|
Linux 开发工具 C语言
Linux 安装 gcc 编译运行 C程序
Linux 安装 gcc 编译运行 C程序
22 0
|
4天前
|
Linux
Linux(5)WIFI/BT调试笔记
Linux(5)WIFI/BT调试笔记
21 0
|
28天前
|
JSON Kubernetes Linux
Linux环境签发CA证书和K8s需要的证书
Linux环境签发CA证书和K8s需要的证书
29 0
|
24天前
|
存储 NoSQL Java
Java数据库编程指南:实现高效数据存储与访问
【4月更文挑战第2天】Java开发者必须掌握数据库编程,尤其是JDBC,它是连接数据库的标准接口。使用Spring JDBC或JPA能简化操作。选择合适的JDBC驱动,如MySQL Connector/J,对性能至关重要。最佳实践包括事务管理、防SQL注入、优化索引和数据库设计。NoSQL数据库如MongoDB也日益重要,Java有对应的驱动支持。理解这些概念和技术是构建高效数据库应用的基础。
Java数据库编程指南:实现高效数据存储与访问
|
15天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
39 6
|
3天前
|
Java
Java配置环境
Java配置环境
10 0
Java配置环境
|
1天前
|
Oracle Java 关系型数据库
Linux环境安装配置JDK11
Linux环境安装配置JDK11
16 0
|
3天前
|
Java Shell Linux
【linux进程控制(三)】进程程序替换--如何自己实现一个bash解释器?
【linux进程控制(三)】进程程序替换--如何自己实现一个bash解释器?
|
4天前
|
Linux Android开发
Linux(6)CH9434 SPI调试笔记
Linux(6)CH9434 SPI调试笔记
13 0
|
8天前
|
安全 Java API
java借助代理ip,解决访问api频繁导致ip被禁的问题
java借助代理ip,解决访问api频繁导致ip被禁的问题