Home arrow static arrow Java Programming [Archive] - vector display!!!! plz urgent
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - vector display!!!! plz urgent
This topic has 5 replies on 1 page.

Posts:2
Registered: 7/21/04
vector display!!!! plz urgent  
Aug 5, 2004 11:56 PM



 
i have a method (getEmail())in a java program -DbBean, this method(getEmail()) calls a class CustInfo().
the values from the CustInfo are stored in a vector in the getEmail() .

i want to display the values from CustInfo in DbBean. Plz help. i am unable to do so while i use
vector.atElement( location of the array)


these are my codes for DbBean1//


public class DbBean1 {

Connection conn = null;
ResultSet rs1 = null;
Statement stmt = null;
String email = null;
//private Vector getEmail;
Vector customerInfo = new Vector();
//Vector getEmail() = new Vector();

String dbURL = "jdbc:informix-sqli://201.4.157.83:1527/vservices:informixserver=ol_vsdbi_tcp;user=informix;password=informix";
String dbDriver = "com.informix.jdbc.IfxDriver";
private Connection dbCon;

public DbBean1() throws Exception{
super();
connect();
check();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection(dbURL);
return true;
}

public void check() throws Exception
{
System.out.println("check");
getEmail();

}


public void close() throws SQLException{
dbCon.close();
}

public void getEmail() throws SQLException
{


try
{

stmt = dbCon.createStatement();
String select1 = "select email from vcs_user ";
System.out.println(select1);
ResultSet c = stmt.executeQuery(select1);
System.out.println("E M A I L");

Vector v = new Vector();
while(c.next())
{
v.add(new CustInfo(c));
//return v;
}

//return v;

for(int i = 0; i<v.size();i++)
{

String cmp = (String)v.elementAt(i);
System.out.println(i+"Emails");

System.out.println(cmp+"CMP");

}


}
catch (SQLException e)
{
System.out.println("ERROR readCpeRegister: " + e);
}

catch (Exception e)
{
System.out.println("ERROR: failed to load Informix JDBC driver - readCpeRegister()");
}

}


public ResultSet execSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;

}

public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

public static void main(String[] args) throws Exception
{

new DbBean1();

}

}

//}


and these are my codes for CustInfo


public class CustInfo
{

String email = null;

public CustInfo(ResultSet rs) throws SQLException
{
System.out.println("Entering Class CustInfo");

this.email = rs.getString("email");
System.out.println(email);

}

String getUname()
{
return email;
}


}


when i compile the codes there are no errors. but when i try to excute them there is driver not found error.if i try to print the emails from CustInfo i can print,i am unable to print the emails at DbBean1.java

Thank U very much in advance

 

Posts:5,119
Registered: 16.08.01
Re: vector display!!!! plz urgent  
Aug 6, 2004 12:10 AM (reply 1 of 5)



 
When you post code, please use [code] and [/code] tags as described in [url=http://forum.java.sun.com/features.jsp#Formatting]Formatting Help[/url] on the message entry page. It makes it much easier to read.
 

Posts:1,995
Registered: 12/10/00
Re: vector display!!!! plz urgent  
Aug 6, 2004 12:19 AM (reply 2 of 5)



 
If it's really urgent then I can give you a tip: it seems you don't even reach the vector display code, you have a problem with the database. Check the driver is in your classpath and you have spelled the class name correctly.

But it's better to learn the basis before working with databases and heavier stuff.

Anyway, marking the question as urgent can only bring yawmark and the Bolivian army at your heels ;)

Mike
 

Posts:2
Registered: 7/21/04
Re: vector display!!!! plz urgent  
Aug 6, 2004 12:39 AM (reply 3 of 5)



 
hi belly,

ofcourse i can connect to the database..as i am able to print the values in my CustInfo
 

Posts:5,904
Registered: 04/03/99
Re: vector display!!!! plz urgent  
Aug 6, 2004 1:16 AM (reply 4 of 5)



 
There's no "of course" about it.

Firstly, we couldn't care less how urgent this is for you, it's not urgent for us.

Please post any subsequent code between the [code] and [/code] tags as recommended [url http://forum.java.sun.com/faq.jsp#format]here[/url].

Please don't catch and mask the exceptions that are thrown during the course of your application. This is the most convenient method for displaying the full information on failure:
...catch( Exception e ) {   e.printStackTrace();}

Once you have made those changes, run the code again, and post the code and the output in these forms (don't forget the code tags).

You've posted the connection, username, and password details of your database here for everyone to see. I recommend that you change your password immediately, and that you don't post it again.

This is nothing to do with vectors. It is everything to do with your database connection.

Finally, before you click "post", click "preview" to make sure you've got everything right.

Dave.
 

Posts:1,995
Registered: 12/10/00
Re: vector display!!!! plz urgent  
Aug 6, 2004 1:31 AM (reply 5 of 5)



 
Nice job, Dave.

Mike
 
This topic has 5 replies on 1 page.