Java+Mysql的数据库查找实现
public class select {
public List XiuGai_select(String keyword){
List list=new ArrayList();
Connection conn = null;
Statement stmt = null;
String sql=null;
ResultSet res = null;
getConnection b=new getConnection();
conn=b.getconnection();
sql="select * from book where bookName like'%"+keyword+"%'";
try {
stmt = conn.createStatement();
res=stmt.executeQuery(sql);
while (res.next()) { //如果结果集不为空,那么取出值输出
int id = res.getInt("id");
String bookName= res.getString("bookName");
String author= res.getString("author");
String publisher= res.getString("publisher");
int isBorrow=res.getInt("isBorrow");
int isRenew=res.getInt("isRenew");
Date dateOfBorrow=res.getDate("dateOfBorrow");
int numberOfBook=res.getInt("numberOfBook");
int numberOfNow=res.getInt("numberOfNow");
int userId=res.getInt("userId");
Book book = new Book(id,bookName,author,publisher,isBorrow,isRenew,dateOfBorrow,numberOfBook,numberOfNow,userId);
list.add(book);
System.out.println(id);
System.out.println(b
相关文档:
java clone
文章分类:Java编程 关键字: java clone
1.java里的clone分为:
A:浅复制(浅克隆): 浅复制仅仅复制所考虑的对象,而不复制它所引用的对象。
b:深复制(深克隆):深复制把要复制的对象所引用的对象都复制了一遍。
Java中对象的克隆,为了获取对象的一份拷贝,我们可以利用Object类的clone()方法。必须要 ......
首先boolean不能跟其他类型转换。
1.赋值时:
整数默认的是int 浮点默认是double,即整型等号右侧全部自动转化为int,浮点型等号右侧自动转换为double。当大容量的数据类型赋值给小容量的数据类型时 需要强制类型转换但是有 ......
if(null != agent && -1 != agent.indexOf("MSIE")){
filename = URLEncoder.encode(filename
,"UTF8");
}else if ......
JSR 203:NIO 2扩展和实现了在Java 1.4中加入的最初NIO功能。在NIO 2中最明显的新增功能就是文件访问API的全面改进。多数开发者都用过java.io.File,对其存在的众多缺陷自然心中有数:
◆不支持符号链接(symbolic links )
......
Ubuntu Linux Install Sun Java Development Kit ( JDK ) and Java Runtime Environment ( JRE )
by Vivek Gite
Q.
How do I install Sun
Java Development Kit (JDK) and Java Runtime Environment (JRE) under
Ubuntu Linux? It appears that there are multiple JRE installed by
default under Ubuntu. ......