Tag Cloud

Blogumulus by Roy Tanck and Amanda Fazani

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.Date;
import java.text.SimpleDateFormat;

public class compareTime
{
public static void main(String[] args)
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver loading success");
}
catch (ClassNotFoundException e)
{
System.out.println("Driver loading fail");
}

try
{
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@IP:PORT:SID","ID","PASSWORD");
System.out.println("Connection Success");
System.out.println("");

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select to_char(systimestamp, 'hh24:mi:ss:ff3') as time from dual");

System.out.println(getTime());

if (rs.next())
{
System.out.println("DB1 Time --> " + rs.getString("time"));
}

System.out.println(getTime());

conn.close();
System.out.println("");
System.out.println("Connection finished");
}
catch (SQLException sqle)
{
System.out.println("Connection fail");
}
catch (IllegalArgumentException ille)
{
System.out.println("IllegalArgument input");
}
}


private static String getTime()
{
SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss:SS");

return "WAS1 Time --> " + sdf.format(new Date());
}
}

0 개의 덧글:

Post a Comment