第二句的意思是,用-Xlint重新编译TryBookDB.java 将得到更多的信息
可是用同包中的对象
可是用同包中的对象
解决方案 »
- SmartUpload上传图片问题
- hibernate删除操作问题
- 在struts2中,按钮的名称怎么实现国际化。谢谢
- struts中利用smartupload上传多个文件时出现的问题,没用到ActionForm
- 在EJB项目的客服端如何使用Servlet文件和如何去配置它
- Tomcat配置好后用时??
- 怎么配置VE,请教大家,谢谢
- 创建多个Statement对象出错的问题
- 关于hibernate配置和SAE MYSQL的问题
- JPA中的EntityManagerImpl与EntityManager, 为何一个接口的实现类无法调用不到接口的某些方法
- 想学习STRUTS,问大侠两问题~
- java程序
package mypack;import java.sql.*;
import java.util.*;public class TryBookDB{
private String dbUrl="jdbc:mysql://localhost:3306/BookDB";
private String dbUser="wulirong";
private String dbPwd="98002129";
public TryBookDB(){
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(Exception e){
e.printStackTrace();
}
}
private Connection getConnection() throws Exception{
return DriverManager.getConnection(dbUrl,dbUser,dbPwd);
}
private void closeConnection(Connection conn){
try{
if(conn!=null)conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
private void closeStatement(Statement stmt){
try{
if(stmt!=null)stmt.close();
}catch(Exception e){
e.printStackTrace();
}
}
private void closeResultSet(ResultSet rs){
try{
if(rs!=null)rs.close();
}catch(Exception e){
e.printStackTrace();
}
}
public Collection getBooks(){
ArrayList books=new ArrayList();
BookDetails book=null;
String sql="select * from books";
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
conn=getConnection();
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
while(rs.next()){
book=new BookDetails(rs.getString("id"),rs.getString("title"),
rs.getString("author"),rs.getFloat("price"));
books.add(book);
}
}catch(Exception e){
e.printStackTrace();
}finally{
closeConnection(conn);
closeStatement(stmt);
closeResultSet(rs);
}
Collections.sort(books);
return books;
}
}package mypack;public class BookDetails{
private String bookId;
private String author;
private String title;
private float price;
public BookDetails(String bookId,String author,String title,float price){
this.bookId=bookId;
this.author=author;
this.title=title;
this.price=price;
}
public String getBookId(){
return bookId;
}
public String getAuthor(){
return author;
}
public String getTitle(){
return title;
}
public float getPrice(){
return price;
}
}
The compiler responds by giving you a warning: Note: GenericArray.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.Those of us who worked with C, especially pre-ANSI C, remember a particular effect of warnings: when you discover you can ignore them, you do. For that reason, it's best to not issue any kind of a message from the compiler unless the programmer must do something about it.
In this case, we've gotten a single warning, and we believe that it's about the cast. But if you really want to make sure, you should run - Xlint:unchecked:
Note: Recompile with -Xlint:unchecked for details.这个警告,我搜了一下好像都是1.5下有的
我怀疑这边问题:
finally{
closeConnection(conn);
closeStatement(stmt);
closeResultSet(rs);
}
顺序不对
应该是rs,stmt,conn
你是不是classpath里面没有那个点啊?就是表示当前路径