MySQL Lists are EOL. Please join:

List:MySQL and Java« Previous MessageNext Message »
From:Robert H. Thompson Date:May 4 1999 4:42pm
Subject:Prepared statement problem
View as plain text  
Hello all, 

I am a java jdk1.2 (blackdown's port) running on Red Hat Linux 5.2
(kernel 2.0.36) , mysql 3.22.21 and mm.mysql.jdbc1.2a jdbc driver for
mysql. I am having a problem executing sql statements. After watching
some of the posts for the last few days I decided to try using prepared
statement in the following context:

    String usrnme = txt_username.getText();
        System.out.println("loading driver");
        Class.forName("");              //loads
the driver
        String url     = "jdbc:mysql://localhost:3306/dev_db";
        Connection con = (Connection) DriverManager.getConnection(url,
null, null);
        PreparedStatement pstmt = (PreparedStatement)
		                          con.prepareStatement("SELECT f_name, l_name,
" +
   				                               "username, password " +
valid_users" +
				                               "WHERE username = ?");
        System.out.println("setting up prepared sql statement");
		System.out.println("passing "+usrnme+" as input to prepared
        pstmt.setString (1,usrnme);
	System.out.println("executing prepared sql statement");
	ResultSet rs = (ResultSet) pstmt.executeQuery();
	catch (Exception ex) 
        System.out.println("Exception: " + ex);
	System.out.println(" ");

When I run the applet that has this code I get the following runtime
error. java.sql.Exception error during query:
Syntax or access violation: parse error near '= 'admin'' at line 1.

to me it seems as though some extra quotes are coming from somewhere.
Anybody have any clues I'd greatly appreciate
it. I am new to java - but not to programming or databases. 


Rob Thompson

Prepared statement problem Robert H. Thompson4 May
  • Re: Prepared statement problem mmatthew4 May
  • Re: Prepared statement problem Oana Radulescu5 May
    • Re: Prepared statement problemChristian Mack5 May