2026-03-12 20:23:15

This commit is contained in:
root
2026-03-12 21:23:47 +01:00
parent eab4b36eca
commit 93039b8489
3332 changed files with 699614 additions and 0 deletions

32
tpt/demos/GetDate.java Normal file
View File

@@ -0,0 +1,32 @@
// run with:
// java -cp $ORACLE_HOME/jdbc/lib/ojdbc6.jar:. GetDate
import java.sql.*;
import oracle.jdbc.OracleConnection;
public class GetDate {
public static void main(String[] args) throws InterruptedException {
try {
// get connection and statement
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@centos7:1521:LIN121", "system","oracle");
Statement stmt = conn.createStatement();
stmt.execute("ALTER SESSION SET time_zone = '-08:00'");
ResultSet rs = stmt.executeQuery("SELECT d FROM t");
// print output from v$session. here you should see this java program's session with client identifier set
System.out.printf("\n%-10s %-10s %-20s\n", "DATE", "TIME", "TIMESTAMP");
System.out.println("-------------------------------------------------");
while (rs.next()) {
System.out.printf("%-10s %-10s %-20s\n", new Object[] {rs.getDate("D").toString(), rs.getTime("D").toString(), rs.getTimestamp("D").toString()} );
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
}