Good time of day!

A small introduction: some time ago, I opened an old (working!) Project, compiled it, uploaded it on Red5 (I had just updated it to the next version).

When restarting, Red5 gave an error message - I can’t load the com.mysql.jdbc.Driver driver.

I found a solution, fixed the problem, after a couple of days I myself distributed advice (it helped me myself then).

I decided to redo the project a little, post the file classes, etc. Has commented on work from a DB. Now I’ve got to rework working with the database - and the guys aren’t working ...

Now the question is: why can java.lang.ClassNotFoundException: com.mysql.jdbc.Driver be thrown ? And how to get around this? Tips of the type to connect / specify the connector will not work - everything has already been done, see below.

I tried mysql-connector-java - *. Jar to shove in different folders (both in the root of the disk, in the project's WEB-INF directory, and in the folder with RED5) did not help. I tried instead of the connector to add a folder with this file to the Build Path (Add Class Folder in Eclipse which), I tried to add the connector along with the folder. I even tried to specify CLASSPATH and the classpath does not help (I use Eclipse - that is, CLASSPATH is not necessarily a bit like). I tried to leave only one CLASSPATH, and from the project to remove the mention - nothing helped ...

Looked - in the .classpath project all the necessary paths are indicated.

True, I read that sometimes it is enough to specify the parameter in the command line - classpath with the desired directory - it has not tried yet, because I did not understand where to specify these parameters for Red5. Can you tell me?

Moreover, if I create a separate JAVA project (not Red5) in the same way, it seems to work there with a database (though I started it with a debugger from IDE). Those. I do everything correctly ... I did not check the work with the database, but



 connInfo.put("characterEncoding","UTF8"); connInfo.put("user", "root"); connInfo.put("password", "root"); cn = DriverManager.getConnection("jdbc:mysql://localhost/db", connInfo); 

There are no exceptions.


mysql-connector-java - *. jar tried both 5.1.18 and 5.1.21.

Red5 - 1.0 RC2.

MySQL client version: 5.0.51a.

Server version: 5.5.21.

Eclipse Java EE IDE for Web Developers. Version: Indigo Service Release 1 Build id: 20110916-0149

    1 answer 1

    I have no idea what kind of beast Red5 judging by Google is some kind of web server sharpened for distribution of media content. If this is the case, then all the concepts of a regular web server are applicable to it, namely when deploying your project to the server, then you need to export the libraries there as well. Apparently, you are not exporting the JDBC library — read the Red5 manuals for where to put the exported libraries (usually web-inf / lib)


    1. CLASSPATH should not be viewed relative to the Eclipse JVM, but relative to the Red5 JVM server, since Class.forName() will search for the class in the CLASSPATH server for loading
    2. I assume the option is that the preferred way to load the JDBC driver is to download via the JNDI DataSource . This is usually done in the server settings, for example, for Tomcat there is such an instruction - I suspect something similar for your Red5 - for example . This is a more professional way to load the JDBC driver in contrast to the self-described in the books "a la HelloWorld"
    • Exactly ... I guessed it, I guessed that Red5 did not see the driver, so I tried to connect it from everywhere, but I didn’t get to% red5% / lib ... Now everything works. Thank. According to paragraph 2: maybe this is the wrong approach, but now it works - and that suits me. A professional approach will be postponed until the next "opening of the old project")) Still doing for myself. The study always begins with "a la HelloWorld", and only then everything else) - BOPOH