?? cateidchoices.java
字號:
package zichan;
import java.sql.*;
import java.math.*;
public class CateIdChoices {
Connection conn;
public CateIdChoices() {
conn = (new DBConnt()).getConnection();
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public int selCateCnt() {
int cnt=0;
if (conn == null) {
System.out.println("Can not connected yet!");
return -1;
}
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery ("select count(distinct cateid) from category");
while (rset.next()) {
cnt = rset.getInt(1);
}
rset.close();
stmt.close();
}
catch (java.sql.SQLException s) {
System.out.println("exception: " + s.getMessage());
}
return cnt;
}
public void selCateId(String [] scnt) {
int k=0;
String sql;
if (conn == null) {
System.out.println("Can not connected yet!");
return;
}
try {
sql = "select distinct cateid from category";
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery (sql);
while (rset.next()) {
scnt[k++] = rset.getString(1);
}
rset.close();
stmt.close();
}
catch (java.sql.SQLException s) {
System.out.println("exception: " + s.getMessage());
}
}
public int selSubCateCnt(String cid) {
int cnt=0;
if (conn == null) {
System.out.println("Can not connected yet!");
return -1;
}
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery ("select count(subcateid) from category where cateid = '"+cid+"'");
while (rset.next()) {
cnt = rset.getInt(1);
}
rset.close();
stmt.close();
}
catch (java.sql.SQLException s) {
System.out.println("exception: " + s.getMessage());
}
return cnt;
}
public void selSubCateId(String [] scnt,String cid) {
int k=0;
String sql;
if (conn == null) {
System.out.println("Can not connected yet!");
return;
}
try {
sql = "select subcateid from category where cateid = '"+cid+"' order by subcateid";
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery (sql);
while (rset.next()) {
scnt[k++] = rset.getString(1);
}
rset.close();
stmt.close();
}
catch (java.sql.SQLException s) {
System.out.println("exception: " + s.getMessage());
}
}
private void jbInit() throws Exception {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -