Connector MXJ Strange Error Question?
"Deepak Shrestha" <[email protected]> Mon, 31 Mar 2008 19:48:50 +0800
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am new to Connector/MXJ. Recently I have downloaded "Connector/MXJ
5.0.9" and "Connetor/J 5.1.6". I am trying to build/test a simple
system tray application from which I can start or shutdown the mysql
database. I am following MySQL 5.1 documentation on MXJ and so far I
was able to run the "ConnectorMXJObjectTestExample.java".
Based on this I created the separate class (called DButils) where I
put the routines to start and stop the database like this:
=====================================
public void InitializeAndStartDatabase() throws Exception {
File dbEngineDir = new File ("E:/MXJTest");
int dbPort = Integer.parseInt(
System.getProperty("My_DB_Port","3336"));
String userName = "hello";
String password = "hello";
mysqldResource = StartDatabase(dbEngineDir, dbPort,
userName, password);
}
public MysqldResource StartDatabase(File databaseDir, int port,
String userName, String password) {
MysqldResource mysqldResource = new MysqldResource(databaseDir);
Map database_options = new HashMap();
database_options.put(MysqldResourceI.PORT, Integer.toString(port));
database_options.put(MysqldResourceI.INITIALIZE_USER, "true");
database_options.put(MysqldResourceI.INITIALIZE_USER_NAME, userName);
database_options.put(MysqldResourceI.INITIALIZE_PASSWORD, password);
mysqldResource.start("test-mysqld-thread", database_options);
if (!mysqldResource.isRunning()) {
throw new RuntimeException("MySQL did not start.");
}
return mysqldResource;
}
public void ShutDownDatabase() {
try {
mysqldResource.shutdown();
}
catch (Exception shtex) {
shtex.printStackTrace();
}
}
====================================
In my main class I have created and initialized the DButils variables
DButils dbUtils = new DButils();
My main app runs as system tray application where I have two three
menu items and action listeners for that. Like this:
=======================================
ActionListener exitListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
};
ActionListener stopDBListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
dbUtils.ShutDownDatabase();
JOptionPane optPane = new JOptionPane();
optPane.showMessageDialog(null,
"Database Successfully Stopped");
}
catch (Exception dbex) {
dbex.printStackTrace();
}
}
};
ActionListener startDBListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
dbUtils.InitializeAndStartDatabase();
JOptionPane optPane = new JOptionPane();
optPane.showMessageDialog(null,
"Movie Database Successfully Started");
}
catch (Exception dbex) {
dbex.printStackTrace();
}
}
};
=======================================
My system tray application works perfectly but when I click the menu
item to start the database, it starts the database but soon after (1
sec), following Error occurs:
[NOTE: I am using Netbeans 5.5 the following is the output I copied]
=======================================
init:
deps-jar:
compile:
run:
[E:\MXJTest\bin\mysqld-nt.exe][--no-defaults][--console][--port=3336][--socket=mysql.sock][--basedir=E:\MXJTest][--datadir=E:\MXJTest\data][--pid-file=E:\MXJTest\data\MysqldResource.pid]
[MysqldResource] launching mysqld (test-mysqld-thread)
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
080331 18:29:10 InnoDB: Setting file .\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
080331 18:29:11 InnoDB: Log file .\ib_logfile0 did not exist: new to be created
InnoDB: Setting log file .\ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
080331 18:29:11 InnoDB: Log file .\ib_logfile1 did not exist: new to be created
InnoDB: Setting log file .\ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
080331 18:29:12 InnoDB: Started; log sequence number 0 0
080331 18:29:12 [Note] E:\MXJTest\bin\mysqld-nt.exe: ready for connections.
Version: '5.0.51a-community-nt' socket: '' port: 3336MySQL Community
Edition (GPL)
[MysqldResource] mysqld running as process: 3624
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
com.mysql.jdbc.Driver
at com.mysql.management.MysqldResource.canConnectToServer(MysqldResource.java:236)
at com.mysql.management.MysqldResource.start(MysqldResource.java:221)
at com.mysql.management.MysqldResource.start(MysqldResource.java:166)
============================================
After this my Shutdown Databse function doesn't work and I have to
manually end the Mysql process form Task Manager (I am using windows).
My Question is:
1) What is this error? Is this Connector/MXJ Specific Error or something else?
2) What is the probable cause of this error? why I am getting this
error while the example that comes with Connector/MXJ is running
perfectly?
Can somebody guide me on this?
Thanks
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/[email protected]