一.如何在linux环境下调试JAVA程序使用访问timesten:
1.配置jdk环境变量:
[timesten@ora11gr2 ~]$ javac
Usage: javac
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
-cp
-sourcepath
-bootclasspath
-extdirs
-endorseddirs
-proc:{none,only} Control whether annotation processing and/or compilation is done.
-processor
-processorpath
-d
-s
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files
-encoding
-source
-target
-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
[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