2009/06/29

关于 Error while evaluating uitoggletool ClickedCallback

环境:

JDK 1.6

Netbeans 6.5

MATLAB Version 7.6 (R2008a)

MATLAB Builder JA Version 2.0.1 (R2008a)

问题:

在一个Java GUI程序中第一次使用由MATLAB Builder JA编译的matlab画图函数时,可以方便的使用zoom in,zoom out 等matlab的figure工具栏。但是当重新计算数据并用相同函数画图时,zoom in,zoom out 等figure工具栏都不可用,并在Netbeans的output中显示:

Error while evaluating uitoggletool ClickedCallback

我首先修改了原matlab程序,在每一个画图命令前都加上‘figure()’命令,但是没有成功:-(

之后我修改了JAVA代码。原先的代码是每按一次画图按钮,便分出一个线程,实例化一个由MATLAB Builder JA编译的Java类,其中就包括那个画图函数,这个函数被Java调用,进行绘图;修改之后,我把实例化的过程放到了GUI程序的构造方法中,也就是每次运行这个Java GUI程序时,由MATLAB Builder JA编译的Java类只会被实例化一次,在GUI程序关闭时才会调用其dispose()方法释放其资源。

修改之后,figure工具栏可以任意使用。 可是此问题的机理还是不太明白。我已发信至其他程序员,希望能得到满意答复。

2009/06/23

"Failed to find the runtime libraries"

I receive a "Failed to find the runtime libraries" error in Netbeans when using the .jar component that was compiled by MATLAB Builder JA 2.0.1 (R2008a) on windows. I searched the solution online, the answer is on

http://www.mathworks.com/support/solutions/en/data/1-78FIKN/index.html?product=MJ

Just add the matlab bin directory to the system PATH, as it instructed. But it didn't work until I restarted the Netbeans IDE.

2009/06/16

"Adding Tab Panels to jTabbedPane using Netbeans"

I am so lucky that I found the solution to the questions stated in the title so quickly!

Thanks to the original blogger:

http://dotnettojava.blogspot.com/2008/07/adding-tab-panels-to-jtabbedpane-using.html

To easily access to it I pasted here, thank you Dot Net To Java:

Adding panels to a tabbed pane was not straight forward until I found the correct procedure. To add panels, select a jpanel from the palette and pull it over to the tabbed pane window. After the first pane, you must place the panel you have grabbed with your mouse over the tabs at the top. Move the panel around until an orange box appears on the tabbed pane. Then you can release the mouse button and the panel will be added as a new tabbed pane panel. If you don't get the orange box, then when you drop the panel, it will become a sub panel on the tabbed pane panel that is currently active. This is not what you want if you are trying to add an additional panel to the tabbed pane. 
Posted by DotNetToJava at 4:04 PM

2009/06/10

Copy the remote database to my local machine

Finnally I succeeded to copy the remote database to my local machine!

1. Log in the remote machine(redhat) via Putty, and cd to the database directory, which consists of the '.frm' '.myd' and 'myi' files.

2. Type command 'zip myDatabase *', which put all the files in the current directory into myDatabase.zip

3. cd the directory where myDatabase.zip locates via psftp, and type the command
'get myDatabase.zip'. Now the myDatabase.zip is on my machine, under the same directory as psfyp.

4. Unzip the file, create a database on local machine, and copy all the file from the zip file to the local database file directory. The database file directory could be found via MySQLAdministrator: Click 'Startup Variables', and then the 'Data Directory' under the 'Directories' is the place where the database table hosts.

Using connection pool in java bean

Now I am using Netbean 6.5 as an IDE, and Glassfish 3 Prelude as a server app.

I tried to use the connection pool provided by Netbean in my java beans, following the help document "Accessing a Connection Pool from a Java Class " in Netbean, but it says no to me ...

I have n0 time to figure it out since my boss is pushing me, so I borrowed the connection pool code from http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html . There are totally 3 java files that is needed to download:


The interface you need is the first class: JDCConnectionDriver

Here's a demonstration code fragment for connecting to the database:

-------------------------------------------------------------------------

new JDCConnectionDriver("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/weblcc", "root", "password");

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/weblcc");

-------------------------------------------------------------------------

now the conn could be used for database operation.

Notice: There might be some problems when you run your code unless you uncomment the 3 lines of code:

// if (!url.startsWith(URL_PREFIX)) {

// return null;

// }

in JDCConnectionDriver.connect(String url, Properties props) method, or change the JDCConnectionDriver.URL_PREFIX from "jdbc:jdc:" to "jdbc:". It depends on your URL.

I have tested the code, and plug it in my web apps. Hope it works well  :-D

2009/06/09

[转]解压版MySQL配置全解

来源:http://hi.baidu.com/lupeng0527/blog/item/7a05931b649637d2ad6e75e0.html

一 下载MySQL

http://dev.mysql.com/downloads/mysql/5.0.html

解压MySQL(F:\Program Files\MySQL\)MySQL安装目录

二 新建my.ini

在F:\Program Files\MySQL\下建立my.ini文件,内容为

my.ini

[mysqld] 

# 设置mysql的安装目录 

basedir=F:\\Program Files\\MySQL

# 设置mysql数据库的数据的存放目录,必须是data,或者是\\xxx-data 

datadir=F:\\Program Files\\MySQL\\data

# 设置mysql服务器的字符集,默认编码

default-character-set=latin1 


[client]

# 设置mysql客户端的字符集

default-character-set=latin1


[WinMySQLAdmin] 

# 指定mysql服务启动启动的文件

Server=F:\\Program Files\\MySQL\\bin\\mysqld.exe



三 注册MySQL服务,使MySQL可以在服务项目中启动或关闭

1)进入安装目录\bin,执行:

  F:\Program Files\MySQL\bin>mysqld -install

  显示:Service successfully installed. 则注册服务成功。

如果要删除服务:

F:\Program Files\MySQL\bin>mysqld -remove

2)修改注册表:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MySQL\ImagePath

修改为:

"F:\Program Files\MySQL\bin\mysqld" --defaults-file=

"F:\Program Files\MySQL\my.ini" MySQL

四 修改root密码

MySQL配置好后,启动成功,默认密码是空,但是为了安全,设置密码(一般用户名为root,密码为root)。

1)登录MySQL root用户:

  进入MySQL安装目录\bin,执行:

  F:\Program Files\MySQL\MySQL-6.0.7\bin>mysql -u root;

2)修改root密码:

  mysql> update mysql.user set password=PASSWORD(''新密码'') where User=''root''; 

  mysql> flush privileges; 

这样配置就可以使用net start mysql命令正常启动MySQL。