On Fri, 15 Mar 2002, Jianping Zhu wrote:
>
> I have spend three days try to get jdbc for mysql work, but failed. I am
> very frustrated. I will
> be appreciated if somebody can help me out.
>
> I have redhat 7.2 OS, I download the sever and client mysql .rpm files and
> instaled it, i believe succssfully. i use command like 'mysqladmin
> version' to test the mysql server, the server seems work fine, I have a
> mysql user account 'jianping' which has been granted all global privilges.
>
> I downloaded the JDBC mm.mysql-2.0.4-bin.jar to my system and set the env
> varible properly.
>
> I have a database called 'evote' and there is one table 'stocks' in the
> database.
> I use the code download form a jDBc tutrial website the code is:
>
> --------------------------------------------------------------------
> import java.sql.*;
> import java.io.*;
> import java.util.*;
>
> class StocksMy {
> public static void main (String args []) {
>
> try {
>
> Class.forName("org.gjt.mm.mysql.Driver").newInstance();
> System.out.println("1111111111111111");
>
> // Create a Connection and a Statement
> Connection conn = DriverManager.getConnection(
>
> "jdbc:mysql://localhost/evote?user=jianping&password=ping1830");
> System.out.println("33333333333333");
> Statement stmt = conn.createStatement();
> // Select all columns from the STOCKS table
> ResultSet rset = stmt.executeQuery ("select * from stocks");
>
> // Iterate through the result and print the records
> while (rset.next()) {
> String ticker=rset.getString(1).trim();
> String title=rset.getString(2).trim();
> String price=rset.getString(3).trim();
> String blanks=
> " ";
> // print the data in a table format
> System.out.print (ticker);
> System.out.print(blanks.substring(1,8-ticker.length()));
> System.out.print (title);
> System.out.print(blanks.substring(1,41-title.length()));
> System.out.println (price);
> }
> } catch (Exception e) {
> System.out.println("StocksMy: JDBC exception");
> System.exit(1);
> }
> }
> }
> ----------------------------------------------------------------------------
> I added some System.out.println () trying to the code.
>
> The code can be compiled succesfully, but when i tried to execute it, it
> gave folliing output.
>
> 11111111111111111
> Stocksmy: JDBC exception
>
> because it did not print 333333333333333 so I believe the problem is that
> the connection can not be establish.
>
> Thanks in advance.
>
>
>
> _______________________________________________
> Redhat-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-list
>
Why don't you print the error ??
tr{
blablabla
}catch ( Exception X ){
System.out.println ( X.getMessage() );
}
this way your java program will tell you what's the problemo
Seguimos ...
leonel;
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php