Can't find class when connecting to db

I have a db in MySQL-Front which I'd like to connect to a java-program.
I'm new to this and don't know what to write but after reading in this forum I've come up with these lines. I suppose that it is the code by the arrows that are my problem. What shall I write there? I've tried a lot and nothing works....
When I run the applet I get the "Class not found" so I guess it is "org.gjt.mm.mysql.Driver" that is my problem. What?
The db is on the same pc as the java-code. At the "DriverManager.getConnection()" i guess I shall write password, login.... But I have no such. I only start my db. What shall I write there?
Help me please!
import java.sql.*;
public class Car {
private String CarNumber;
private String Color;
private String Type;
private static Connection dbconn=null;
public Car (String car, String color, String type) {
CarNumber = car;
Color = color;
Type = type;
public Car() {}
public String getCarNumber() {return CarNumber;}
public String getType() {return Type;}
public String getColor() {return Color;}
public static boolean connect() throws SQLException {
- - - - - -> try {Class.forName("org.gjt.mm.mysql.Driver");}
catch (ClassNotFoundException e) {
System.err.println("Class not found");
(Runtime.getRuntime()).exit(1);
- - - - - -> dbconn = DriverManager.getConnection("????????????");
return dbconn !=null;
public static Car findCar (String seekCarNumber) throws SQLException {
PreparedStatement select = dbconn.prepareStatement("SELECT CarNumber, Color, Type" +
"FROM Car WHERE CarNumber =?");
select.setString(1,seekCarNumber);
ResultSet rs= select.executeQuery();
rs.next();
String n=rs.getString("CarNumber");
String c=rs.getString("Color");
String t=rs.getString("Type");
return new Car(n,c,t);

Your database should provide a JDBC driver JAR or something similar. Your Applet will need to make sure this is on its classpath (assuming it's called mysql.jar):
<applet code="..." archive="mysql.jar">
</applet>You should search the JDBC forum - Applets connecting to databases seem to be very popular (don't ask me why).

Similar Messages

  • Can't find class when executing javabean test

    Hi,
    I've installed Sunone 6.0
    JSP is installed
    JDK is installed
    I've written and compiled a simple javabeans program
    and it generates class correctly.
    When I try to execute I get "Can't find class" error.
    Where does the class need to reside after compiling?
    Is my PATH hosed?
    Thanks for any pointer
    Willie

    hi
    did you get a chance to read this doc:
    http://docs.sun.com/source/817-6251/pwajsp.html

  • Can't find class when i use java.awt.Panel

    I got a Pocket PC with CE 3.0
    I made my first PJava application just a few hours ago. And it works fine. But when i introduce a Panel to improve the interface then application fails on the Pocket PC with the error message "could not find class application". When i remove the Panel it works fine again.
    I thought that java.awt.* is part of PJava. And even if not i should be able to introduce even a java.lang.* class to the PJava application if i use the JAR.
    Any suggestion?

    you should provide more detail about your deployment procedures.
    There are many ways to get this message. AWT in fact is part of pJava and works fine for most of us. So I assume the deployment is the problem. Have you checked the actual content of the JAR? Have you provided a path statement? How do you call your app (shortcut?)

  • Can't find camera when connected

    I've connected a new canon camera and can down load photos through LR4 and iphoto but I cannot find the camera in devices. I have wiped some photos from the card and was hoping to use rescue pro to find them but without a card reader or card slot on the computer my only way of connecting the camera is through the usb but as I said the camera does not appear anywhere. Any suggestions?

    Hi TwoGragons
    I find my cameras in Photobooth.  I don't ever recall them being separate icons as in some Windows applicatiosn that I have used.
    Cheers

  • I tried to download a game on my iphone 4 but it says I need the ios 4.3 update. My phone doesn't say there are any updates available and I can't find it when I connect to itunes. What do I do?

    I tried to download a game on my iphone 4 but it says I the iOS 4.3 update. My doesn't say an udate is available and I can't find it when I connect to itunes.

    Update to the current version of iTunes on the computer.
    Update the iOS on the device.

  • I've downloaded Beyond Adobe - Trial Version but, when I try to open it it says it can't find an internet connection. Internet is connected and working. What can I do?

    I've downloaded Beyond Adobe - Trial Version but, when I try to open it it says it can't find an internet connection. Internet is connected and working. What can I do?

    This is the Reader forum. Are you sure there is an Adobe program called Beyond Adobe?

  • Can't find class org/apache/jk/apr/AprImpl

    Hi
    I have Tomcat 4.1.29 and Apache Web Server 2.0.48 installed.
    I have used this tutorial since I'm a newbie :(
    http://www.gregoire.org/howto/Apache2_Jk2_TC4.1.x_JSDK1.4.x.html
    My problem is when I try to regroup them, I obtained this error error.log.
    error] Can't find class org/apache/jk/apr/AprImpl
    java.lang.NoClassDefFoundError: javax/management/MBeanRegistration
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.access$100(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.access$100(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Here is my confid file (workers.properties) :
    [logger]
    level=DEBUG
    [config:]
    #file=C:/Apache2/conf/workers2.properties
    file=C:/Apache2/conf/workers2.properties
    debug=0
    debugEnv=0
    [uriMap:]
    info=Maps the requests. Options: debug
    debug=0
    # Alternate file logger
    #[logger.file:0]
    #level=DEBUG
    #file=C:/Apache2/logs/jk2.log
    [shm:]
    info=Scoreboard. Required for reconfiguration and status with multiprocess servers
    file=C:/Apache2/logs/jk2.shm
    size=1000000
    debug=0
    disabled=0
    [workerEnv:]
    info=Global server options
    timing=1
    debug=0
    # Default Native Logger (apache2 or win32 )
    # can be overriden to a file logger, useful
    # when tracing win32 related issues
    #logger=logger.file:0
    [lb:lb]
    info=Default load balancer.
    debug=0
    #[lb:lb_1]
    #info=A second load balancer.
    #debug=0
    [channel.socket:localhost:8009]
    info=Ajp13 forwarding over socket
    debug=0
    tomcatId=localhost:8009
    #[channel.socket:localhost:8019]
    #info=A second tomcat instance.
    #debug=0
    #tomcatId=localhost:8019
    #lb_factor=1
    #group=lb
    #group=lb_1
    #disabled=0
    #[channel.un:/opt/33/work/jk2.socket]
    #info=A second channel connecting to localhost:8019 via unix socket
    #tomcatId=localhost:8019
    #lb_factor=1
    #debug=0
    [channel.jni:jni]
    info=The jni channel, used if tomcat is started inprocess
    [status:]
    info=Status worker, displays runtime informations
    [vm:]
    info=Parameters used to load a JVM in the server process
    #JVM=C:\jdk\jre\bin\hotspot\jvm.dll
    OPT=-Djava.class.path=c:/Tomcat/bin/tomcat-jni.jar;c:/Tomcat/server/lib/commons-logging.jar
    OPT=-Dtomcat.home=${TOMCAT_HOME}
    OPT=-Dcatalina.home=${TOMCAT_HOME}
    OPT=-Xmx128M
    #OPT=-Djava.compiler=NONE
    disabled=0
    [worker.jni:onStartup]
    info=Command to be executed by the VM on startup. This one will start tomcat.
    class=org/apache/jk/apr/TomcatStarter
    ARG=start
    disabled=0
    stdout=C:/Apache2/logs/stdout.log
    stderr=C:/Apache2/logs/stderr.log
    [worker.jni:onShutdown]
    info=Command to be executed by the VM on shutdown. This one will stop tomcat.
    class=org/apache/jk/apr/TomcatStarter
    ARG=stop
    disabled=0
    [uri:/jkstatus/*]
    info=Display status information and checks the config file for changes.
    group=status:
    #[uri:127.0.0.1:8003]
    #info=Example virtual host. Make sure myVirtualHost is in /etc/hosts to test it
    #alias=myVirtualHost:8003
    #[uri:127.0.0.1:8003/ex]
    #info=Example webapp in the virtual host. It'll go to lb_1 ( i.e. localhost:8019 )
    #context=/ex
    #group=lb_1
    [uri:/examples]
    info=Example webapp in the default context.
    context=/examples
    debug=0
    #[uri:/examples1/*]
    #info=A second webapp, this time going to the second tomcat only.
    #group=lb_1
    #debug=0
    [uri:/examples/servlets/*]
    info=Prefix mapping
    [uri:/examples/*.jsp]
    info=Extension mapping
    [uri:/examples/*]
    info=Map the whole webapp
    [uri:/examples/servlets/HelloW]
    info=Exampel with debug enabled.
    debug=10
    Thank you for your time !
    Max

    Btw: I get the warning starting IIS - It seems to me that IIS tries to load Tomcat on-the-fly. The Tomcat load the fails and IIS continues to load successfully.
    The beginning of the IIS Event log outputs this:
    Apache Jakarta Connector2, Information, Info: [jk_vm_default.c (340)]: vm.detach() ok
    Apache Jakarta Connector2, Warning, Error: [jk_worker_jni.c (308)]: Can't find class org/apache/jk/apr/AprImpl
    Apache Jakarta Connector2, Information, Info: [jk_worker_jni.c (297)]: Loaded org/apache/jk/apr/TomcatStarter
    Apache Jakarta Connector2, None, Debug: [jk_vm_default.c (302)]: vm.attach() allready attached
    Apache Jakarta Connector2, Information, Info: [jk_worker_jni.c (252)]: jni.validate() class= org/apache/jk/apr/TomcatStarter
    Apache Jakarta Connector2, Information, Info: [jk_vm_default.c (607)]: vm.open2() done
    Apache Jakarta Connector2, Information, Info: [jk_vm_default.c (500)]: vm.init(): Jni lib: C:\wwwapps\j2sdk1.4.2_01\jre\bin\client\jvm.dll
    /watson

  • I've lost my iPhone 4... How can I find it when the device is offline when using "find my iPhone app"????? Any way of getting a location from it????

    I've lost my iPhone 4... How can I find it when the device is off linesmen using "find my iPhone app"????? Any way of getting a location from it?????

    No. It must be online in order to locate it.
    What To Do If Your iDevice Is Lost Or Stolen
    iPhone, iPod Touch, and iPad
    If you activated Find My Phone before it was lost or stolen, you can track it only if it is connected to the Internet by Wi-Fi or cellular. What you cannot do is track your device using a serial number or other identifying number. You cannot expect Apple or anyone else to find your device for you. You cannot recover your loss unless you insure your device for such loss. It is not covered by your warranty.
    If your iPhone, iPod, iPod Touch, or iPad is lost or stolen what do you do? There are things you should have done in advance - before you lost it or it was stolen - and some things to do after the fact. Here are some suggestions:
    This link, Re: Help! I misplaced / lost my iPhone 5 today morning in delta Chelsea hotel downtown an I am not able to track it. Please help!, has some good advice regarding your options when your iDevice is lost or stolen.
      1. Reporting a lost or stolen Apple product
      2. Find my lost iPod Touch
      3. AT&T. Sprint, and Verizon can block stolen phones/tablets
      4. What-To-Do-When-Iphone-Is-Stolen
      5. iCloud- Use Lost Mode
      6. What to do if your iOS device is lost or stolen
      7. 6 Ways to Track and Recover Your Lost/Stolen iPhone
      8. Find My iPhone
      9. Report Stolen iPad | Stolen Lost Found Online
    It pays to be proactive by following the advice on using Find My Phone before you lose your device:
      1. Find My iPhone
      2. Setup your iDevice on iCloud
      3. OS X Lion/Mountain Lion- About Find My Mac
      4. How To Set Up Free Find Your iPhone (Even on Unsupported Devices)

  • ERROR: Can't find class Startadmin

    Hello,
    why do I get this error message:
    Can't find class Startadmin
    I want to start my class Startadmin.java with "java Startadmin"!
    The file is in the current path, so I tried "java -classpath .: Startadmin" too, but I sill get this error!
    What can I do?

    Can you please post the solution, I'm having similar problem.
    I set the classpath before compiling the program
    export CLASSPATH=/usr/java/lib/classes.zip:/oracle/product/8.1.6/demo/lib/classes111.zip
    When I try to run the program at the command prompt
    $ java JdbcTest
    I am getting error message "Can't find class JdbcTest"
    When tried
    $ java -classpath . JdbcTest
    I was getting different error message
    java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver at JdbcTest.main(Compiled Code)
    Any help is appreiated
    Thanks
    SJ

  • Error: Can't find Class

    Hi there,
    I have added an external library (jtom) to my project. I get this runtime error when running my midlet:
    Error: Can't find Class jtom.service.JTOMException.
    When I extract the contents of the library(jtom), I can see that the class (jtom.service.JTOMException) exists. I can also see this class in myProject>>Build>>compiled folder.
    I'm using Netbeans Mobility 5.5
    Please Assist,
    Pheks

    Can you please post the solution, I'm having similar problem.
    I set the classpath before compiling the program
    export CLASSPATH=/usr/java/lib/classes.zip:/oracle/product/8.1.6/demo/lib/classes111.zip
    When I try to run the program at the command prompt
    $ java JdbcTest
    I am getting error message "Can't find class JdbcTest"
    When tried
    $ java -classpath . JdbcTest
    I was getting different error message
    java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver at JdbcTest.main(Compiled Code)
    Any help is appreiated
    Thanks
    SJ

  • HELP - 'Can't find class' error

    I have just bought a new computer with Windows XP and downloaded and installed the new versions of the jdk, jre, etc.
    I have written the Hello World program to check that everything works. It compiles fine, but when I try to run I get an error - Can't find class helloworld - and then it exits.
    I know that the path variable is set correctly and I used to have to set the classpath as well, but have been told that this is not necessary.
    I really need to get this working as have some important programming to do.
    Thanks for any help,
    Olly

    Try this;-
    prompt>set CLASSPATH=
    .......> return key
    prompt>java helloWorld
    Hello World!
    prompt>
    AMAZING!
    This works fine. Thanx.
    Is there any way to set it so that I dont have to do
    the set classpath stuff each time I run a program
    though?
    CheersWell, set a system variable
    CLASSPATH=.;<java_home>\jre\lib\rt.jar
    regardws, Thomas

  • Can't find class error on Tru64 UNIX

    I have written a class, TextProcessor, and I can compile and run it without any problems on my Win2K box. I ftp the source to works Tru64 box and compile the class just fine. When I issue the command "java TextProcessor" I get the msg "Can't find class TextProcessor". I immediately thought I had a classpath issue. I messed around with setting my classpath but without luck.
    I then wrote a new class on the Unix box using vi called Hello.java. I compile the Hello class without a problem. I issue the command "java Hello" and get "Hello!", just like I am supposed to get.
    The 2 classes reside in the same directory, TextProcessor does not have any package statements. I am totaly confused.
    Environment information:
    Tru64 UNIX version 5 or so.
    JDK 1.1.8 (not my choice and I have no control over the JDK)
    JRE 1.2.2 is also installed.
    Please help!
    Thanks

    Maybe.....
    Make sure that you have the permissions necesary to read,write and execute the file from your own account.
    If you canno't find any class maybe is because you cannot read.
    What account are you used to pute the file from Win?
    you can try this...
    chmod 777 TextProcessor.java
    chmod 777 TextProcessor.class
    But......????? uhmmmmmm??
    I'm not sure, because If you can compile then you can read the file, but it's depends you umask ......
    it's only a suggest

  • "can't find class" error

    i have win xp as my OS and jdk1.1.8 installed. I have my class path set correctly. I have changed the environment variable to c:\jdk1.1.8\bin
    When I compile my java programs using javac at the command prompt, the program compiles successfully and the class file is made but when I run it I get the erro "can't find class filename"
    I there some other way to set the class path in XP .
    I don't understand where I am going wrong.
    Please help...

    to run a java file you would type c:\jdk1.1.8\bin\java ClassName
    leave it at that, i think the error your getting is caused when you type the .class extention ie. c:\jdk1.1.8\bin\java ClassName.class

  • Query engine : Can not find DSN in Connection String

    DearSir/Madam,
    Opearating System Windows 7 Professional(32-bit).
    I am using Application, which is developed : Visual basic 6.0(32-bit), Report Writer : Crystal Report 9.2.693(32-bit) and database: Oracle 9.2.0.10(32-bit).
    ODBC Data source : System DSN created and Connection established (Based on Driver : CR ORACLE ODBC Driver 4.10 (cror818.dll))
    In windows 7 environment Data Base connectivity and data fetching also wroking fine.
    My problem is while running reports it display error as "Query engine : Can not find DSN in Connection String"
    I want run time reports.
    For your kind information, at the same time in Windows XP Professional there is no problem found and working fine.
    Kindly help me.
    Thanks and regards,
    Swarup

    Crystal Reports 9.x is not supported on Win 7. See the following wiki:
    http://wiki.sdn.sap.com/wiki/x/b4JiAw
    - Ludek

  • I get itunes can't find file when I tried to play a TV show I had purchased that was supposed to be in the cloud. There are several of these, including an entire season. In the store it shows that I purchased these shows when I checked them.

    I get itunes can't find file when I tried to play a TV show I had purchased. I then checked and had this problem with an entire TV season I had purchesed. The shows were supposed to be in the cloud. I went to the itunes store, went to the tv shows and they showed that I had purchesed them. They do not show up when I click on purchesed in the store.

    Try this...
    Empty/corrupt library after upgrade/crash
    Hopefully it's not been too long since you last upgraded iTunes, in fact if you get an empty/incomplete library immediately after upgrading then with the following steps you shouldn't lose a thing or need to do any further housekeeping. In the Previous iTunes Libraries folder should be a number of dated iTunes Library files. Take the most recent of these and copy it into the iTunes folder. Rename iTunes Library.itl as iTunes Library (Corrupt).itl and then rename the restored file as iTunes Library.itl. Start iTunes. Should all be good, bar any recent additions to or deletions from your library.
    See iTunes Folder Watch for a tool to catch up with any changes since the backup file was created.
    When you get it all working make a backup!
    tt2

Maybe you are looking for

  • Error while starting NW server and j2ee server is getting stopped.

    Hi, I am working in NW04s. It contains ABAP sp5 and java sp9 versions. The server was working find till ten days back. After the gap of ten days, when i started to work on this SAP system, i was not able to start the j2ee server. During the startup o

  • Recording problem on my Xi-Fi Fatality?

    'Recording problem on my Xi-Fi Fatality?d So I have a Xi-Fi Fatality, and I would like to be able to record directly from my computer so that it's own output is also the input. For example, if I'm on ventrillo or something and I want to play a funny

  • Can anyone get my iMovie to stop crashing?

    Here is the report.  No thrid-party QT components that I can find.  Uninstalled Flip4Mac.  Trashed plists.  Freed up memory.  Thought it might be related to the little Photo Booth clip in the project so I duplicated and deleted that clip.  No dice. 

  • How can I d/l an old version of FCPX?

    How can I download an old version of FCPX (specifically 10.0.9, for Snow Leopard) through the app store? I purchased it a couple years ago, but now I have to re-install it. Thanks.

  • How to update all pages on my website at once with CSS

    Hi everyone, Ive designed a site using CSS (Thanks to others on the forum..:) and have a column on the right of the homepage for latest news...rather than having to update 30+ pages one by one possibly each week....how can I make changes to my homepa