cateidchoices.java
来自「一个资产管理系统的源码」· Java 代码 · 共 105 行
JAVA
105 行
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 + =
减小字号Ctrl + -
显示快捷键?