jEdit Community - Resources for users of the jEdit Text Editor
com.mysql.jdbc.Driver not found
Submitted by Cheo on Monday, 2 June, 2008 - 10:40
Hi all

I've got a Netbeans web project working perfectly in my Debian box. I'm using the MVC pattern and would like to give jEdit a go for unit testing my Model.

I'm using a MySQL server, but cannot make my Model work because the com.mysql.jdbc.Driver is not found during run time. It compiles fine.

In my Project Viewer plugin, I right-clicked in my project->Properties->SQL Server Configuration and added my MySQL server.
I'm using the SQL pluggin and have set up the Driver's classpath by doing Plugins->Plugin Options->SQL->JDBS and adding the file mysql-connector-java-5.1.6-bin.jar. I can run queries in the SQL plugin with no problem and see the results in the SQL Result Set.
I have even added the mysql-connector-java-5.1.6-bin.jar file manually into ~/.jedit/jars as well.

So, I don't really know what is the problem. Any help will be appreciated.

Best regards,

Sergio
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Where exactly is the problem?
by elberry on Mon, 02/06/2008 - 15:22
Where exactly is the problem? From what you've explained everything is working. You've installed the SQLPlugin, and changed your project-viewer properties so you can execute SQL queries against your database. It sounds like that was successful.

How are you "testing your model"? Are you trying to run some beanshell script against your model? Are you using another plugin (JUnitPlugin?) to run test cases against your model through jEdit?

Please explain further.


Learn from the past. Live in the present. Plan for the future.
11101000
 
The problem is that when I ru
by Cheo on Tue, 03/06/2008 - 11:02
The problem is that when I run the file with the methods I want to test, it cannot find the mysql driver.

I simply load the files I want to test in jEdit, compile them and run a particular file. It compiles fine, but it doesn't run for the reason mentioned before: it doesn't find the driver.

The very same code runs perfectly in a Netbean project, so I assume I'm missing something in jEdit regarding on how to set up the mysql driver.
 
K. You're still not being ver
by elberry on Tue, 03/06/2008 - 16:57
K. You're still not being very clear as to your issue, but I think I get the gist of it.

You're using SQLPlugin to run sql queries against your database: Works

You're using XYZ Plugin to compile and run a particular file: Compile works, running doesn't.

Question 1: What XYZ Plugin are you using to compile and run?

Question 2: How are you using the mysql driver? Meaning, are you using the DriverManager, some dependency injection api like Spring, some database pooling api like dbcp, or something else?

Regardless, it sounds like it's a classpath issue. jEdit plugins use the JARClassLoader that comes with jEdit. If you're using the DriverManager, you won't be able to find the Driver unless it's in the System classpath - which NB sets up for you (through ant).

This might help explain better:
http://community.jedit.org/?q=node/view/3812

Depending on how you're using the Driver, and how you're compiling and running your files there might be solutions.

Thanks.

Learn from the past. Live in the present. Plan for the future.
11101000
Blog
 
To compile and run I'm just u
by Cheo on Tue, 03/06/2008 - 20:12
To compile and run I'm just using the Console plugin.
This is my code. This may answer your second question:



package data;

import java.io.*;
import business.Member;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class IOMember {

/*
* Create a new member
*/
public void saveMember(Member m){

Connection connection = getConnection();

try {
// make the prepared statement
PreparedStatement create = connection.prepareStatement(
"INSERT INTO mytable SET " +
"title=?, " +
"forename=?, " +
"surname=?, " +
"postcode=?, " +
"email=?, " +
"age=?, " +
"ms_type=?; ");

// set the attributes
create.setString(1, m.getTitle());
create.setString(2, m.getForename());
create.setString(3, m.getSurname());
create.setString(4, m.getPostCode());
create.setString(5, m.getEmail());
create.setString(6, m.getAge());
create.setString(7, m.getMembershipType());

// execute the prepared statement
create.executeUpdate();

// close prepared statement
create.close();

// close connection
connection.close();
}
catch(SQLException sqle) {
System.out.println("Failed to create record: " + sqle);
}
}



/*
* private method to obtain a new connection
*/
private Connection getConnection() {

try {

Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/UHI";
String user = "user";
String pass = "pass";
Connection connection = DriverManager.getConnection(url,user,pass);
return(connection);
}
catch(ClassNotFoundException cnfe) {
System.out.println("Could not find DB driver: " + cnfe);
}
catch(SQLException sqle) {
System.out.println("SQL Exception in getConnection(): " + sqle);
}
return(null);

}



/*****************************************************
* UNIT TESTING
*****************************************************/

public static void main(String[] args) {

IOMember iom = new IOMember();

/*
* SAVE MEMBER
*/
Member member = new Member("Mr", "John", "Doe", "12345",
"john@doe.com", "34", "All inclusive");
iom.saveMember(member);
/**/
}


}
User login
Browse archives
« April 2024  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82348
Context Free Art (*.cfdg)   0.31   46055
JBuilder scheme   .001   18495
BBEdit scheme   1.0   18116
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293