简体   繁体   中英

Database Driver connection problems in JDBC

I am developing an app in Java with Netbeans 6.9.1 as the IDE. I use a MySQL database, and connect to it using JDBC.

I have a curious problem.

Class.forName() does not throw ClassNotFoundException in one package, whereas it throws it in another. What might be wrong?

JDK version is 1.6 and I am using Ubuntu 10.10.

If you use to connect mysql with netbeans, you may have to do the steps in the following link. -----> Netbeans Help

Class.forName() does not throw ClassNotFoundException in one package, whereas it throws it in another. What might be wrong?

The only two scenarios I can think of for this are:

  1. One package is an application package and the other is a test package. In this case, you'd have to make sure Connector/J is added to the regular library list and the test library list as well.

  2. They're two different projects, at which rate you'd have to add Connector/J to both projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM