📄 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 + -