Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

new programmers simpleish error help wanted

0 views
Skip to first unread message

vivienne wykes

unread,
Jul 20, 2004, 7:50:14 PM7/20/04
to
Hi all
I have two classes listed below .A Test class ScrubWedding class. I get the
errors listed below when I use the Test class to run the ScrubWedding class.
Could anyone with some insight pass it on . I would appreciate it greatly.

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.
技舷


Murray

unread,
Jul 20, 2004, 8:05:17 PM7/20/04
to

"vivienne wykes" <vw011...@blueyonder.co.uk> wrote in message
news:WciLc.86576$q8.5...@fe1.news.blueyonder.co.uk...

> 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 + "'"


Shane Mingins

unread,
Jul 20, 2004, 8:15:52 PM7/20/04
to
"vivienne wykes" <vw011...@blueyonder.co.uk> wrote in message
news:WciLc.86576

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/


Liz

unread,
Jul 20, 2004, 8:43:49 PM7/20/04
to

"Shane Mingins" <shanem...@yahoo.com.clothes> wrote in message
news:40fdb3c8$1...@news.iconz.co.nz...
I copied the mysql driver to my pc and then put in the path to the local jar
file.


vivienne wykes

unread,
Jul 21, 2004, 5:25:36 PM7/21/04
to
Thanks Murray,

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

0 new messages