如何在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

 

 

你可能感兴趣的:(linux,profile,目录,Export,java程序)