Regards
Jim Ascroft
package com.bloodoo;
import java.util.*;
import java.sql.*;
public class Test
{
public Test(){ }
public static void main (String args[])
{
String current = "";
ScrubWedding scrub = new ScrubWedding();
scrub.removeWedding(current);
}
}
public my ScrubWedding(){ }
public void removeWedding(String wedding_to_remove)
{
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
System.out.println ("after Class.forname");
java.sql.Connection connection =
java.sql.DriverManager.getConnection("jdbc:mysql://localhost/shop");
java.sql.Statement statement = connection.createStatement();
System.out.println ("afterconnection.createStatement");
statement.executeUpdate("DELETE FROM items WHERE jedi_id =
'weding_to_remove'");
if (statement != null )
statement.close();
if ( connection != null )
connection.close();
}
catch(Exception e)
{
e.printStackTrace(System.err) ;
}
}
}
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
舷 at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
舷 at java.security.AccessController.doPrivileged(Native Method)
舷 at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
舷 at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
舷 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
舷 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
舷 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
舷 at java.lang.Class.forName0(Native Method)
舷 at java.lang.Class.forName(Class.java:141)
舷 at com.bloodoo.ScrubWedding.removeWedding(ScrubWedding.java:20)
舷 at com.bloodoo.Test.main(Test.java:17)
舷
舷 ----jGRASP wedge2: exit code for process is 0.
舷┫ ----jGRASP: operation complete.
技舷
> java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
Is the MySQL driver in your classpath?
> statement.executeUpdate("DELETE FROM items WHERE jedi_id =
> 'weding_to_remove'");
Maybe this was just for testing or something, but just in case it wasn't: I
don't think this will do what you want it to do. This will delete all ITEMS
with jedi_id = 'wedding_to_remove' <-- actual String, not the value of your
String variable.
"DELETE FROM items WHERE jedi_id = '" + wedding_to_remove + "'"
Start here ...
> java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
Cannot find the class org.gjt.mm.mysql.Driver. Which probably means that 1.
it is not in the classpath or 2. you haven't downloaded or 3. both :-)
Could I please encourage you to do the Java tutorials, they cover lots of
the Java basics.
Oh, and if you really want to write a test for a class or method in a class
... try www.junit.org JUnit is the standard Java unit test framework. It
would also be well worth your time to get to know it, IMO.
Shane
--
The most intelligent Java IDE around -- http://www.intellij.com/idea/
I know String wedding_to_remove is being passed in to my class and if I hard
code a weddingid value of say 5 the bean removes all wedding id 5 entries
in the database.
However I cant seem to be able to pass in wedding_to_remove into this
line ---statement.executeUpdate("DELETE FROM items WHERE weddingid = '" +
wedding_to_remove + "'");
Any insight greatfully accepted.
Regards
package com.bloodoo;
import java.util.*;
import java.sql.*;
public class ScrubWedding
{
//String weddingid ;
java.sql.PreparedStatement statement;
java.sql.Connection connection;
String wedding_to_remove;
public ScrubWedding(){ }
public void removeWedding(String wedding_to_remove)
{
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
System.out.println ("after Class.forname");
java.sql.Connection connection =
java.sql.DriverManager.getConnection("jdbc:mysql://localhost/shop");
java.sql.Statement statement = connection.createStatement();
statement.executeUpdate("DELETE FROM items WHERE weddingid = '" +
wedding_to_remove + "'");
//String output = "wedding_to_remove";
//JOptionPane.showMessageDialog(null,output,"A message to
help",JOptionPane.INFORMATION_MESSAGE);
System.out.println ("after executeUpdate");
if (statement != null )
statement.close();
if ( connection != null )
connection.close();
}
catch(Exception e)
{
e.printStackTrace(System.err) ;
}
}
}
"Murray" <pa...@SMAFFoffSPAMMER.optusnet.SPAMMAGE.com.au> wrote in message
news:1riLc.9511$K53....@news-server.bigpond.net.au...