Hello all. This is a snippet from my JavaBean that I'm using to insert data
into MySql database.
The bean is working perfectly alright but I can't insert data into the user
table. Please help and do tell what I'm doing wrong here.

This is the code:

public String saveToDB() {
  try {
   Class.forName("org.gjt.mm.mysql.Driver").newInstance();
   try {
    cn = DriverManager.getConnection("jdbc:mysql://localhost/users");
    try{
     Statement st = cn.createStatement();
     String sql = "insert into user Values('"+userName+"','"+password1+"')";
     st.executeQuery(sql);
     return "success";
    }
    catch(SQLException e){
     return e.toString();
    }
   }
   catch(SQLException e){
    return e.toString();
   }
  }
  catch(ClassNotFoundException e){
   return e.toString();
  }
  catch(Exception e) {
   return e.toString();
  }
 }

Thanks.

Rohit.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.237 / Virus Database: 115 - Release Date: 07/03/2001



---------------------------------------------------------------------
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

Reply via email to