J2ee|mysql
This period of time in learning J2EE&EJB, I am most interested in doing JDBC EJB, but because I do not have the default Cloudscape on hand, also dare not install Oracle, my machine too, run the EE is full load operation, can not add big! So I would like to continue to use small and small MySQL.
First of all, of course, the installation of system environment software, I will not say more, in the following I gave several software download address. In particular, please be sure to pay attention to the version of MySQL you installed, we usually use the "Mysql-shareware-3.22.30-win" version, but the Java EE need 3.23.15 more MySQL, this is the lesson I spent a long time to get.
After my many experiments, Java EE configuration file default properties should be set as follows:
Jdbc.drivers=org.gjt.mm.mysql.driver
Jdbc.datasources=jdbc/testdb|jdbc:mysql://localhost:3306/test?user=jian&password=jian
The above statement is very simple, using MySQL JDBC driver people to see the Ming, the note is that the "Jdbc/testdb" is actually jndi used to identify the database name.
It's easy to call in an EJB:
DataSource ds = (DataSource) ic.lookup ("Jdbc/testdb");
In fact, after the correct configuration to look back to see, it is really very simple, but it is right before a period of groping process cost me a lot of energy, the so-called dark before the dawn.
From the point of view of my use, this version of the Java EE error mechanism is very poor, seemingly unintelligible, and unstable, such as the use of its assembly tools generated jar package, although available, but each time the system pop-up warning is "Invalid Windows NT image", annoying, and, I have been able to successfully run the EJB connection MySQL by the above configuration, but Error.log and dos Windows always record "cannot find principal mapping information for data source with JNDI Name Jdbc/testdb ". However, although there are warnings and error log records, but as long as your program can run smoothly, do not have to pay attention to so many, after all, the Java EE is only a new thing, not after a long period of wide range of evaluation and use.
Operating Environment:
J2EE:JAVATM 2 SDK, Enterprise Edition Version 1.2.1
jdk:j2sdk1.3.0
Mysql:mysql-3.23.23-beta-win
driver:mm.mysql-2.0.2