📄 searchaction.java
字号:
package com.ivan.bookSearch;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import com.ivan.db.Database;
public class SearchAction
{
public static Vector<String[]> getRowData(String s[])
{
Vector<String[]> v = new Vector<String[]>();
String method = s[0];
String text=s[1];
String sql="select bookName,book.ISBN,bookId,author,press,edition,language,status,loc " +
"from program.book,program.bookitem ";
if("书名".equals(method))
sql+= "where bookname like '%" + text+"%' and bookitem.ISBN=book.ISBN";
else if("ISBN".equals(method))
sql+="where book.ISBN='"+text+"' and bookitem.ISBN=book.ISBN";
else if("馆藏号".equals(method))
sql+="where bookId ='" + text+"' and bookitem.ISBN=book.ISBN";
else
sql+="where bookitem.ISBN=book.ISBN";
Connection connection;
ResultSet rs=null;
connection = Database.getConnection(); //建立数据库连接
Statement stmt=null;
int cou=0;
try
{
stmt= connection.createStatement();
rs=stmt.executeQuery(sql);
while(rs.next())
{
cou++;
String[] rowdata=new String[9];
for(int i=1;i<10;i++)
rowdata[i-1]=rs.getString(i);
v.addElement(rowdata);
}
System.out.print(cou);
return v;
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
connection.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -