java的Date类 运行不了,求解。。。。
package DATE;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TestDate {
public static void main(String[] args) throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection ct=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL","scott","j123");
Statement sm=ct.createStatement();
ResultSet rs=sm.executeQuery("select HIREDATE from emp");
while (rs.next() ){
Date d=rs.getDate("HIREDATE");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd");
System.out.println(sdf.format(d));
}
rs.close();
sm.close();
ct.close();
}
}
------解决方案--------------------
Exception in thread "main"
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver平时看到错误的时候找个工具翻译一下,你就知道问题了。这明显说的是oracle.jdbc.driver.OracleDriver的Class没有找到,那意思就是你oracle的驱动包没有引入导致的错误。下个oracle的jar包引入就好
------解决方案--------------------
Exception in thread "main"
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
oracle的驱动包有没有加到项目中或者jdk环境中啊 ?