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());
}
}
Music Playlist
zdnet
Favorite Links
About Me
Labels
- Android (1)
- Augmented Reality (1)
- Blog Design (2)
- book (1)
- certification (1)
- Cloud Computing (1)
- Database (1)
- Environment Setting (1)
- Game (1)
- Info (3)
- iPhone (1)
- J2EE (1)
- JAVA (5)
- JSP (1)
- Mobile (4)
- News (2)
- Operating System(UNIX) (1)
- phrase (1)
- Policy (1)
- Scrap (1)
- security (1)
- Services (1)
- Servlet (1)
- Terms (1)
Tag Cloud
Blogumulus by Roy Tanck and Amanda Fazani
작성자:
Doyoung Lee
24 July 2009
레이블:
JAVA
Subscribe to:
Post Comments (Atom)