package Business;
import java.sql.*;
import java.util.ArrayList;
/**
* @author Justin
*/
public class Accounts {
String acctID;
String custID;
String type;
double balance;
public Accounts(){
acctID = "";
custID = "";
type = "";
balance = 0;
}
public Accounts(String c, String i, String t, double B)/>{
acctID = c;
custID = i;
type = t;
balance = b;
}
public void setAcctID(String c){acctID = c;}
public String getAcctID() {return acctID;}
public void setCustID(String i){custID = i;}
public String getCustID() {return custID;}
public void setType(String t){type = t;}
public String getType() {return type;}
public void setBalance(double B)/>{balance = b;}
public double getBalance() {return balance;}
public boolean getAccountsList() {
boolean a = false;
String Url="jdbc:mysql://localhost:3306/chattbank";
String dbId="root";
String dbPass="root";
try {
Class.forName("core.log.jdbc.driver.MysqlDriver");
Connection connection = DriverManager.getConnection
(Url,dbId ,dbPass );
Statement statement = connection.createStatement();
String cmd = "select * from accounts where cID = " + getCustID();
ResultSet rs = statement.executeQuery(cmd);
ArrayList<String> result = new ArrayList<String>();
while(rs.next());
connection.close();
}
catch(Exception ex){
System.out.println(ex);
return false;
}
return a;
}
}
Getting Data from DB to arraylist
Page 1 of 12 Replies - 92 Views - Last Post: 18 November 2012 - 10:08 AM
#1
Getting Data from DB to arraylist
Posted 18 November 2012 - 08:43 AM
Hello guys, I'm having some trouble with getting data from a MySQL table, to an arraylist. It's inside a web application, an Accounts object makes the connection and uses the preparedstatement and such. I've scoured the internet looking to find how to accomplish this but I can't make much sense of it. Any suggestions?
Replies To: Getting Data from DB to arraylist
#2
Re: Getting Data from DB to arraylist
Posted 18 November 2012 - 09:17 AM
#3
Re: Getting Data from DB to arraylist
Posted 18 November 2012 - 10:08 AM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|