或者是:
16
SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" );
17
Date date = format.parse( myString );
5. 使用 JDBC 链接 Oracle
18
public class OracleJdbcTest
19
{
20
String driverClass = "oracle.jdbc.driver.OracleDriver";
21
22
Connection con;
23
24
public void init(FileInputStream fs) throws ClassNotFoundException, SQLException,
FileNotFoundException, IOException
25
{
26
Properties props = new Properties();
27
props.load(fs);
28
String url = props.getProperty("db.url");
29
String userName = props.getProperty("db.user");
30
String password = props.getProperty("db.password");
31
Class.forName(driverClass);
32
33
con=DriverManager.getConnection(url, userName, password);
34
}
35
36
public void fetch() throws SQLException, IOException
37
{
38
PreparedStatement ps = con.prepareStatement("select SYSDATE from dual");
39
ResultSet rs = ps.executeQuery();
40
41
while (rs.next())
42
{
43
// do the thing you do