}
//根据用户积分,获得用户可以享受的折扣
public float getUserRate(String userid)
{
int userPoint=this.getUserPoint(userid);
int lerver=userPoint/100;
switch (lerver)
{
case 0:return 1.0f;
case 1:return 0.95f;
case 2:return 0.90f;
case 3:return 0.85f;
case 4:return 0.80f;
case 5:return 0.75f;
default:return 0.75f;
}
}
public String getGbk( String str) {
try {
return new String(str.getBytes("ISO8859-1"));
}catch (Exception e){
return str;
}
}
public int getPage() { //显示的页码
return page;
}
public void setPage(int newpage) {
page = newpage;
}
public int getPageSize(){ //每页显示的CD数
return pageSize;
}
public void setPageSize(int newpsize) {
pageSize = newpsize;
}
public int getPageCount() { //页面总数
return pageCount;
}
public void setPageCount(int newpcount) {
pageCount = newpcount;
}
public long getRecordCount() {
return recordCount;
}
public void setRecordCount(long newrcount) {
recordCount= newrcount;
}
public String getMessage() {
return message;
}
public void setMessage(String msg) {
message = msg;
}
public void setUserid(long uid) {
userid = uid;
}
public long getUserid() {
return userid;
}
public void setUserName(String uName) {
username = uName;
}
public String getUserName() {
return username;
}
public Vector getUserlist() {
return userlist;
}
};
Util包:
DataBase.java:
package cdshop.util;
/**
* <p>数据库连接专用包 </p>
* <p>Copyright: wxy Copyright (c) 2004</p>
* <p>Company:CD Shop </p>
* @by :wxy
* @version 1.0
*/
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class DataBase {
public Connection conn;
public Statement stmt;
public ResultSet rs=null;
public InitialContext ctx=null;
DataSource ds = null;
public String sqlStr="";
public DataBase() {
this.connect();
}
public boolean connect(){
/* try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/cdStore?user=wxy&useUnicode=true&characterEncoding=8859_1";
conn=DriverManager.getConnection(url);
stmt = conn.createStatement ();
}catch(Exception ee){
System.out.println("connect db error:"+ee.getMessage());
return false;
}
*/
/* try{
ctx = new InitialContext();
if (ctx == null)
throw new Exception("没有匹配的上下文环境");
ds = (DataSource) ctx.lookup("java:comp/env/jdbc/SqlServermidp");
if (ds == null)
throw new Exception("没有匹配的数据库");
conn = ds.getConnection();
stmt=conn.createStatement();
}catch(Exception ee){
System.out.println("connect db error:"+ee.getMessage());
return false;
}
*/
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1305;DatabaseName=cdstore";
String user="sa";
String password="sa";
conn= DriverManager.getConnection(url,user,password);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
}catch(Exception ee){
System.out.println("connect db error:"+ee.getMessage());
return false;
} return true;
}
public void close()
{
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] 下一页