# 2
I have post the coding. Apologies for codeing line is to big.
1. I have single user can execute its working well.
if go for multi-user its not working
public double spin(Hashtable hbettype,int rndno)throws Exception
{
/*************/
bet_names=hbettype.keys();
while(bet_names.hasMoreElements())
{
String check=(String)bet_names.nextElement();
System.out.println("Bet type"+check+" bet value"+hbettype.get(check));
}
System.out.println(hbettype.size());
int len=hbettype.size();
/*****Hashtables contains no of bet types . get the bet types concat in to string becuase
*we passing the query in sql server. mainly query statement bet type search and get result
**/
bet_names=hbettype.keys();
String str="";
int i=0;
while(bet_names.hasMoreElements())
{
i++;
if(i==(hbettype.size()))
{
str = str + "[" + rndno +"] ='"+(String)bet_names.nextElement()+"'";
}
else
{
str = str + "[" + rndno +"]='"+(String)bet_names.nextElement()+"' or";
}
}
System.out.println(str);
String strquery="select ["+rndno+"] from Imm_tblCasinoRouletteBetTypes where "+str;
System.out.println(strquery);
try{
Connection con=null;
Statement stmt= null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
prourl = "jdbc:odbc:IMM_GAMELOGICS";
con = DriverManager.getConnection(prourl,"Sa","1234");
stmt=con.createStatement();
// stmt.execute(strquery);
// rs=stmt.getResultSet();
rs =stmt.executeQuery(strquery);
while(rs.next())
{
//Type casting
String rndcols=String.valueOf(rndno);
vec.addElement(rs.getString(rndcols));
//check_no[index] = rs.getString(rndcols);
//index++;
}
rs.close();
stmt.close();
// con.close();
}catch(Exception e)
{
System.out.println("1.Roulette Game Logics Bet types Exception"+e);
//try{
//fileout.write(e);
//}catch(Exception e1){}
}
finally{
if(con!=null)
{
try{
con.close();
}catch(Exception e)
{
System.out.println("1....Connection close "+e);
}
}
}
tranid = firstInseration();
System.out.println("transid"+tranid);
int index=0;
bet_names=hbettype.keys();
String st;
String ve;
System.out.println("vector"+vec);
System.out.println("Vector Size"+vec.size());
for(int v=0;v<vec.size();v++)
{
bet_names=hbettype.keys();
while(bet_names.hasMoreElements())
{
st=(String)bet_names.nextElement();
System.out.println(st+"--"+vec.get(v));// passing int
ve = String.valueOf(vec.get(v)); // no of items
if( ve.trim().equals(st.trim()) )
{
System.out.println("sdfdsfsf"+vec.get(v) );
System.out.println(ve+"vs"+st);
//"select payout from roulette_payout where bettype ='"+ve.trim()+"'"
int pays=0;
try
{
Connection con=null;
Statement stmt= null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
prourl = "jdbc:odbc:Imm_gamelogics";
con = DriverManager.getConnection(prourl,"Sa","1234");
//con = objdbconnect.DbconImmgGamelogics();//getDbConnection("IMM_GAMELOGICS");
stmt=con.createStatement();
String strquery1="select payout from Imm_tblCasinoPayoutRoulette where BettypeID ='"+ve.trim()+"'";
System.out.println(strquery1);
//rs1=stmt1.executeQuery("select payout from roulette_payout where bettype ='B'" );
rs=stmt.executeQuery(strquery1);
// System.out.println(strquery1);
if( rs.next())
{
pays=rs.getInt("payout");
System.out.println(pays);
}
} catch(Exception e){
System.out.println("Exception in spin method "+e);
}finally{
try{
if(con!=null){
con.close();
con = null;
}/*
if(rs!=null){
rs.close();
}
if(stmt!=null){
stmt.close();
}*/
}catch(Exception e){
System.out.println("Exception in Connection closing for spincheck spin ist close ");
}
}
double betamount=0.00f;
double winamount=0.00f;
betamount =((Double)hbettype.get(st)).doubleValue();
winamount=((Double)hbettype.get(st)).doubleValue() * pays;
try
{
Connection con=null;
Statement stmt= null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
prourl = "jdbc:odbc:IMM_TRANSACTIONS";
con = DriverManager.getConnection(prourl,"Sa","1234");
// con = objdbconnect.DbconImmTransactions();//getDbConnection("IMM_TRANSACTIONS");
stmt=con.createStatement();
int rows=0;
rows =stmt.executeUpdate("insert into Imm_tblGameDetailsRoulette values("+tranid+",'"+rndno+"','"+ve.trim()+"',"+betamount+","+ winamount+",'1')");
System.out.println("winning "+((Double)hbettype.get(st)).doubleValue());
System.out.println(hbettype.get(st));
cashout =cashout+ ((Double)hbettype.get(st)).doubleValue()* pays;
System.out.println("insdie"+cashout);
hbettype.remove(st);
//and remove the fields from Hashtable
} catch(Exception e){
System.out.println("Exception in spin method in spincheckmethod second getconnection "+e);
}finally{
try{
if(con!=null){
con.close();
con = null;
}/*
if(rs!=null){
rs.close();
}
if(stmt!=null){
stmt.close();
}*/
}catch(Exception e){
System.out.println("Exception in Connection closing for spincheck spin ist close ");
}
}
}
/* else
{
System.out.println("losing "+((Double)hbettype.get(st)).doubleValue());
if(hbettype.get(st)!=null)
{
cashin = cashin+((Double)hbettype.get(st)).doubleValue();
}
}
*/
}
}
try{
Connection con=null;
Statement stmt= null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
prourl = "jdbc:odbc:IMM_TRANSACTIONS";
con = DriverManager.getConnection(prourl,"Sa","1234");
}catch(Exception e)
{
System.out.println("EE "+e);
}
bet_names=hbettype.keys();
while(bet_names.hasMoreElements())
{
st=(String)bet_names.nextElement();
System.out.println(hbettype.get(st));
try{
Connection con=null;
Statement stmt= null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
prourl = "jdbc:odbc:IMM_TRANSACTIONS";
con = DriverManager.getConnection(prourl,"Sa","1234");
// // con = objdbconnect.DbconImmTransactions();//getDbConnection("IMM_TRANSACTIONS");
stmt=con.createStatement();
int rows=0;
double winamount=0.00;
double betamount=0.00;
betamount =((Double)hbettype.get(st)).doubleValue();
rows =stmt.executeUpdate("insert into Imm_tblGameDetailsRoulette values("+tranid+" ,'"+rndno+"','"+st.trim()+"',"+betamount+","+ winamount+",'0')");
}catch(Exception e1){
System.out.println("Exception in spin method in spincheck "+e1);
}
finally{
try{
if(con!=null){
con.close();
con = null;
}
}catch(Exception e){
System.out.println("Exception in Connection closing for spincheck spin 3rd close ");
}
}
cashin = cashin+((Double)hbettype.get(st)).doubleValue();
}
return cashout;
}
Thanks for your reply
please check it. ......>