一次偶尔的机会,我把java包里的内容反编译出来,在sql包里看到了这些接口,有些不解,sql包里这两个都是接口,
却不知道比如Statement.java里的 int executeUpdate(String sql) throws SQLException;
只是一个没有任何内容的方法,我想知道他是怎么具体实现的,比如executeUpdate是怎么实现的,为什么只要调用了executeUpdate
就会有相应的内容方法实现
比如Statement.executeUpdate(sql);
还有就是接口中Statement CreateStatement() throws SQLException;
可以调用其它接口,实现的还是一个接口,这样我觉得没有什么意义,这使我对接口越来越陌生了,高手指教,我在think in java里没有找到答案
我学java一年多了
我总感觉java隐藏了很多方法的实现
我的QQ:258047864
以下是sql反编译的内容:
Connection.javapackage java.sql.*;
public interface Connection {
Statement CreateStatement() throws SQLException;
PreparedStatement preparestatement(String sql) throws SQLException;
CallableStatement prepareCall(String sql) throws SQLException;
void setAutoCommit(boolean autoCommit) throws SQLException;
boolean getAutoCommit() throws SQLException;
void commit() throws SQLException;
void rollback() throws SQLException;
......
}Statement.javapackage java.sql.*;
public interface Connection {
ResultSet executeQuery(String sql) throws SQLException;
int executeUpdate(String sql) throws SQLException;
void Close() throws SQLException;
......
}
却不知道比如Statement.java里的 int executeUpdate(String sql) throws SQLException;
只是一个没有任何内容的方法,我想知道他是怎么具体实现的,比如executeUpdate是怎么实现的,为什么只要调用了executeUpdate
就会有相应的内容方法实现
比如Statement.executeUpdate(sql);
还有就是接口中Statement CreateStatement() throws SQLException;
可以调用其它接口,实现的还是一个接口,这样我觉得没有什么意义,这使我对接口越来越陌生了,高手指教,我在think in java里没有找到答案
我学java一年多了
我总感觉java隐藏了很多方法的实现
我的QQ:258047864
以下是sql反编译的内容:
Connection.javapackage java.sql.*;
public interface Connection {
Statement CreateStatement() throws SQLException;
PreparedStatement preparestatement(String sql) throws SQLException;
CallableStatement prepareCall(String sql) throws SQLException;
void setAutoCommit(boolean autoCommit) throws SQLException;
boolean getAutoCommit() throws SQLException;
void commit() throws SQLException;
void rollback() throws SQLException;
......
}Statement.javapackage java.sql.*;
public interface Connection {
ResultSet executeQuery(String sql) throws SQLException;
int executeUpdate(String sql) throws SQLException;
void Close() throws SQLException;
......
}
记得你怎样取得DB Connection吗?
首先要加载驱动,Class.forName("XXXX.XXXX.XXXX.Driver")
然后DriverManager.getConnection(XXXX)
然后才进行数据库操作
搂主需要补充基础知识
而且,Java类库是不需要反编译的,而是有源代码的
高手要休息了。