MYSQL Driver in JBoss for BMP
Hi
I think For CMP bean there is no need to load the jdbcdriver in the Bean when using J Boss as a Application Server. EJB Container will laod the driver if we gave appropriate path I am USing JBoss 4.04 Application server . I copied mySQl driver into the lib folder . My main question in which .xml i need to configure my SQL jdbc driver driver name,so that EJB Container will load automatically when i start the Application Server
Thanks in Advance
Raghu
The application server doesn't do the Class.forName() call for you, no matter how you configure it. I'd suggest finding the appropriate life-cycle method to put the call in yourself. Possibilities are: ejbLoad(), ejbStore() or init() of some servlet that uses the BMP Entity.
Brian
Similar Messages
-
Help me i need mm.mysql driver for my sql
i tried to connect my jsp page with mysql database but it is giving me type 4 org.gjt.mm.mysql.Driver error it says that it is not found.
i went to mysql official site and it is saying that they have finished mm driver and now have made connector j driver for jdbc ....
my code is this...
<%
Class.forName("org.gjt.mm.mysql.Driver");
Connection myConn= DriverManager.getConnection("jdbc:mysql:///poll?user=123&password=123");
Statement stmt=myConn.createStatement();
ResultSet myResultSet=stmt.executeQuery("select * from pollInfo");
if (myResultSet != null){
while (myResultSet.next()){
String name=myResultSet.getString ("pollname");
String option=myResultSet.getString ("pollOption");
String votes=myResultSet.getString ("pollvotes");%>
<tr>
<td><%=name%></td>
<td><%=option%></td>
<td><%=votes%></td>
</tr>
<%
stmt.close();
myConn.close();
%>
here poll is my database name and pollInfo is my table name
user name and passwords are 123
and when running it it give me this error.
>>>>>>>>>>>>>>>>>>>>>
500 Internal Server Error
/dbquery.jsp:
Exception thrown on line '11' from page 'C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\dbquery.jsp'.
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver [org.gjt.mm.mysql.Driver]
at allaire.jrun.servlet.JRunServletLoader.loadClass(../servlet/JRunServletLoader.java:430)
at java.lang.ClassLoader.loadClass(Unknown Source)
at allaire.jrun.jsp.JSPClassLoader.loadClass(../jsp/JSPClassLoader.java:118)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at jrun__dbquery2ejspc._jspService(jrun__dbquery2ejspc.java:44)
at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:39)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:196)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
at allaire.jrun.session.JRunSessionService.service(../session/JRunSessionService.java:1082)
at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:89)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I am using jrun 3.1 the release of Allair ...
now any one please help me what to do
i willl be great ful to all of u very much thanx
byeHi,
The driver needs to be on your classpath. So download it to (say C:\jars), what I do is rename it to mysql.jar
Then add the C:\jars\mysql.jar to the classpath
If you are using it with tomcat at runtime, which you are probably not, then you could also copy the jar in the tomcat\lib directory - but I have never done this.
If you are still experiencing problems, open the jar file using winxip or the jar command and make sure that the jar build is exactly as it should be, i.e. the correct names etc.
best
kev -
How to load mysql driver in netbeans 5.0
I configured mysql driver(com.mysql.jdbc.Driver) in netbeans 5.0. but i got this type of errors
(run:
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at gdb.gdbop.main(gdbop.java:20))
plz help me for this...............IDEs such as netbeans and eclipse require you to add any external jars to the project's classpath.
for netbeans 5.0, see here:
http://www.netbeans.org/kb/50/using-netbeans/project_setup.html#pgfId-1157099 -
Does anyone know of a good link, regarding the setup of a Mysql jdbc driver on a Unix platform. I need to setup a test page and do not know which *.jar file should be referenced in the classpath. Is it a matter of just downloading the [???] jar file or should I make use of connectors?
Thanx in advanceHi,
I have been using MySQL with Java on both windows and Linux for a while now. All I had to do was to
1) Download the mm.mysql-2.0.11-bin.jar file from www.mysql.com
2) Include this JAR file in the classpath.
3) Open a connection to the database using code like this:
String driverClass = "org.gjt.mm.mysql.Driver",
String url = "jdbc:mysql://localhost/databaseName",
String user = "root",
String password = "");
Class.forName(driverClass).newInstance();
Connection connection = DriverManager.getConnection(url, user, password);
This should do the job.
If you are looking for an easy way of reading and writing objects in databases, I suggest you take a look at the Mr. Persister API that we are releasing on monday May 3rd. It is free, and it does all the tedious and boring work of JDBC for you, with only 5% overhead compared to custom JDBC code. Mr. Persister was developed on MySQL, so it will also work with your project. Check it out here:
http://www.jenkov.dk/projects/mrpersister/mrpersister.jsp
Kind Regards,
Jakob Jenkov
www.jenkov.com -
Strange behaviour of jdbc-mysql driver
I am trying to store japanese characters in mysql and display also after reading from the database using JSP. I am using the following code.
<%@ page contentType="text/html; charset=UTF-8"%>
....... some code ......
<%
Class.forName( "org.gjt.mm.mysql.Driver" );
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DB?useUnicode=true&characterEncoding=UTF-8", "user", "pass" );
Statement st = con.createStatement();
st.executeUpdate( "insert into test values('" + request.getParameter( "imgname" ) + "')" );
ResultSet rs = st.executeQuery( "select * from test" );
while( rs.next() ) {
%> DB Value: <%= rs.getString( "imgname" ) %>
<% } %>
I found one strange behaviour. I have to change the DriverManger.getConnection line to the following, to write the data correctly in the database.
DriverManager.getConnection("jdbc:mysql://localhost:3306/DB","user","pass")
If I read from the database using the same parameters as above, I am getting garbled data.
To retrieve the data correctly from the database I have to use the following line instead of the previous one.
DriverManager.getConnection("jdbc:mysql://localhost:3306/DB?useUnicode=true&characterEncoding=UTF-8", "user", "pass" );
In short, I have to pass different parameters to DriverManager.getConnection() for writing and reading from the database. But it is not possible practically. I am using mm.mysql-2.0.8 jdbc-mysql driver, mysql is 3.23.47 and english windows 2000.
I have tried the string.getBytes("UTF-8") and new String( getBytes(string), "UTF-8") methods, but not getting the correct data.
Can anybody guide me how can I store and display the japanese character correctly?
Thanks to all,
gaurang.I downloaded the latese driver from sourceforge, but still the same thing is happening. Is there any other thing which I should do?
Thanks
gaurang. -
How to import MySQL Driver in Jbuilder
I am creating a GUI application using swing with the help of JBuilder. I have used MySQL as Database. For connection it to java I've used MySQL J-Connector Driver. But I am not being able to import that driver(classes) in jbuilder.
When i run the application at the cmd prompt it works fine (got connected), but when i try to run it under jbuilder it gives error like
java.com.mysql.Driver class not found.
I think it is classpath problem
Please help me, setting this problemNo, you need not import class as you give qualified
class name in Class.forName(). Better post your code
here. Somebody will help you out.Below is the code of CLASS CreateConnection, I'm using to create connection to MySQL. I instantiate this class and use the connection. This class is being called when a connection to database is required. I am creating a desktop application using swing.
package project1;
import java.sql.*;
public class CreateConnection {
private String host,database,username,password;
String db_string;
Connection conn;
Statement smt;
ResultSet rs;
//Parameterized constructor
CreateConnection(String host, String database, String username, String password){
this.host=host;
this.database=database;
this.username=username;
this.password=password;
db_string="jdbc:mysql://"+host+"/"+database+"?user="+username+"&password="+password ;
create();
//Parameterized constructor 2
CreateConnection(String db_string){
this.db_string=db_string;
create();
public void create(){
System.out.println("using: " +db_string);
try{
System.out.println("Loading drivers........");
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("Driver loaded !");
conn = DriverManager.getConnection(db_string);
smt = conn.createStatement();
System.out.println("testing database .........");
smt.execute("create table test(no varchar(22))");
catch(Exception e){
System.out.println(e);
System.exit(0);
System.out.println("Successfull");
public ResultSet execute_q(String query){
try{
System.out.println("Executing "+query);
rs=smt.executeQuery(query);
catch(SQLException sqle){
System.out.println("Execption thrown" +sqle);
return null;
return rs;
} -
"cannot create jbcd driver of class " for connect URL 'null'" error
I am trying to get an application that is currently working fine on a Windows platform to work in a Linux environment.
One thing that is different from my setup in Windows, and also one that I have no experience with, is the Linux-Ubuntu default install of Apache uses Virtual Hosts and Tomcat's equivalent multiple sessions.
I'm running the app out of the usr/share/tomcat6/webapps/msgboard instance of Tomcat vs var/lib/tomcat6.
I am calling the application from Apache Virtual Host port 80 using mod_jk. The application cannot run under native Tomcat because of the extensive use of PHP. Everything else in the application is working correctly including a DWR (Ajax) servlet. However I also tried a simple test app from native Tomcat and got the same results.
I also tried connecting with jdbc:mysql://localhost:3306/msgboard?autoreconnect=true&user=root&password=password at the terminal prompt and got
bash: jdbc:mysql://localhost/msgboard?autoreconnect=true: No such file or directory
[1]7074
[2] 7048
[1] Exit 127 jdbc:mysql://localhost/msgboard?autoreconnect=true
[2]+ Donesyslog error is
Feb 23, 2009 3:01:51 PM org.directwebremoting.util.CommonsLoggingOutput info INFO: Exec: Online.getPosts()
Feb 23 15:01:51 ubuntu jsvc.exec[6779]: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Feb 23 15:01:51 ubuntu jsvc.exec[6779]: Caused by: java.sql.SQLException: No suitable driverFollowing is all the pertinent setup info for reference and critique. Any suggestions would be greatly appreciated.
Apache2.2
Tomcat6
JDBC
mod_jk
Java (not sure what ver, it's the default Ubuntu install ver.)
PHP
Currently I am pointing to mysql-connector-java.jar in my CLASSPATH at /usr/share/java/mysql-connector-java.jar added symlinks commons-dbcp.jar, commons-logging.jar to usr/share/tomcat6/lib
Application is deployed from usr/share/tomcat6/webapps/msgboard
The basic code snippet in class calling the jdbc
WEB-INF/classes/dbLink.class
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/msgboardDB");
WEB-INF/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="msgboard">
<display-name>Message Board</display-name>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/msgboardDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
META-INF/context.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Context path="/msgboard" docBase="msgboard"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/msgboardDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root"
password="thePassword"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/msgboard?autoReconnect=true"/>
</Context>
I also included a symlink to this in var/lib/tomcat6/config named msgboard.xml
per instruction at http://ubuntuforums.org/showthread.php?t=430133 and have since removed it.
my.cnf
[client]
port = 3306
bind-address = 127.0.0.1
permissions set in /etc/tomcat6/policy.d/04webapps.policy
permission java.net.SocketPermission "127.0.0.1:3306", "connect,resolve,listen,accept";
per instruction at http://ubuntuforums.org/showthread.php?t=430133
other permiissions set /etc/tomcat6/policy.d/50local.policy
grant codeBase "file:/usr/share/tomcat6/webapps/msgboard/-" {
permission java.net.SocketPermission "127.0.0.1:3306", "connect,resolve,listen,accept";
grant codeBase "file:/usr/share/tomcat6/webapps/msgboard/WEB-INF/classes/-" {
permission java.io.FilePermission "/usr/share/tomcat6/webapps/msgboard/WEB-INF/classes/logging.properties", "read";
grant codeBase "jar:file:/usr/share/tomcat6/webapps/msgboard/WEB-INF/lib/mysql-connector-java-5.1.6.jar!/-" {
permission java.net.SocketPermission "127.0.0.1:3306", "connect,resolve,listen,accept";
I even tried setting Tomcat Security to "no" per instruction at
http://webui.sourcelabs.com/ubuntu/mail/user/threads/Tomcat_connecting_to_MySQL_-Ubuntu8.10_Server.meta
http://ubuntuforums.org/showthread.php?t=1034957&highlight=apache+tomcat+jdbc
http://ubuntuforums.org/showthread.php?t=66615
http://ubuntuforums.org/showthread.php?t=33601&highlight=java+mysql
http://ubuntuforums.org/showthread.php?t=430133
http://programminglinuxblog.blogspot.com/2008/03/connection-pooling-with-java-all.html
http://webui.sourcelabs.com/ubuntu/mail/user/threads/Tomcat_connecting_to_MySQL_-Ubuntu8.10_Server.metaSOLUTION
I had to add
<Resource name="jdbc/webappDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root"
password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/webapp?autoReconnect=true"/>into /var/lib/tomcat6/conf/Catalina/localhost/ webapp.xml
Note: the above context file was created automatically after deploying the webapp. I had to add the <resource> to it.
The context I created in usr/share/tomcat_home/webapp/META_INF/context.xml is still there and has the same <resource>.defined in it. I did not verify whether or not it still needs to be there.
After that I had to add two policies
/var/lib/tomcat6/conf/policy.d/03catalina.policy
grant {
permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.dbcp.*";
and 04webapps.policy
permission java.net.SocketPermission "127.0.0.1:3306", "connect,resolve,listen,accept";
That did the trick!
Other things that were done but have not been verified as to have any bearing on this issue.
I changed the active java from openjdk to java-sun
I added $tomcat_home/lib:$tomcat_home/lib/mysql-connector.jar:$tomcat_home/lib/commons-dbcp.jar to PATH
Changed CLASSPATH=usr/share/classpath:usr/share/java/commons-dbcp.jar:usr/share/java/mysql-connector.jar
Edited by: wlbragg on Feb 25, 2009 12:58 AM
Edited by: wlbragg on Feb 25, 2009 12:59 AM
Edited by: wlbragg on Feb 25, 2009 1:11 AM -
The MySQL driver exception!!
Hi guys, I got a problem with the MySQL driver. I have installed the MySQL connector to classpath. Then I wrote a test program to test if the driver is working well. This test program showed very thing is working well. This test program can connect the database and pick up data from there.However, when I wrote another program that must be using MySQL, the exception "com.mysql.jdbc.Driver" occured. That looked like the MySQL driver has not been installed well or is not working well. But how this happened? How can I solve this problem???
Thanks a lot.Hi,thanks a lot for ur reply.
Another problem in this case is that, I have 2 computers running this "problem" program. Acturely, most of job have been done in 1st machine and this "problem" program works very well. Then for some reasons, I gotta move this "problem" program to 2nd machine. At first, I just move the .class file to 2nd machine, but it appears exception"com.mysql.jdbc.Driver". Then I move all the source code and compile it. It also appears the same exception. Does that mean the classpath in 2nd machine has some problems?
Thanks for any reply. -
Kodo not recovering from bad connection in new MySQL driver
Hi,
I'm using kodo 2.4.1 and the latest stable MySQL driver 3.0.6. After
leaving the application inactive for a few hours, the connection to
mysql is no longer usable. This did not occur with MySQL version 2.0.14
(as I believe Kodo weren't reusing the connections).
Are there any properties that I could set, so Kodo can keep the
connection active or recover from the problem?
MakasOk, thanks Marc, like I said though, I am now re-using MySQL 2.0.14
driver. I'm not sure if I'm gaining any advantages with MySQL 3.0.6 anyway.
But I'll probably upgrade it after the next Kodo is released.
Makas
Marc Prud'hommeaux wrote:
Makas-
Sorry ... I didn't test the property I sent. The problem is that our
options parsing does not deal with spaces (this will be fixed in the
next release).
Instead of ValidateConnectionSQL="SELECT 1", you should be able to use
ValidateConnectionSQL=SELECT(1), which does not contain spaces.
In article <[email protected]>, Makas Tzavellas wrote:
Marc,
Using the properties you wrote, kodo doesn't seems to be able to parse
it. I've also tried various other combinations with no success. I'm now
going to use the older mysql driver.
Marc Prud'hommeaux wrote:
Makas-
Kodo should be re-using the MySQL Connection in exactly the same way,
regardless of the version. The problem is that it looks like MySQL people
slipped in an "optimization" into 3.0.6 whereby Connection.isClosed()
does not actually test the state of the Connection, but instead just
returns true if and only if Connection.close() has been invoked.
You can get around this by specifying some SQL to validate the
Connections. The following property should do the trick:
com.solarmetric.kodo.impl.jdbc.DictionaryProperties=\
ValidateConnections=true \
ValidateConnectionSQL="SELECT 1"
Please let us know if the problem persists.
In article <[email protected]>, Makas Tzavellas wrote:
Hi Marc,
Here're the stack trace of the exception and the kodo properties. There
isn't any long running transaction. The application is basically left
idle for some time and subsequent connections fails. It could be
connections obtained from the pool, but I'm not sure.
I will re-use mysql 2.0.14 for now. Please let me know if I'm missing
any other properties or if you need more info.
# Kodo JDO Properties configuration
# To evaluate or purchase a license key, visit http://www.solarmetric.com
com.solarmetric.kodo.CacheReferenceSize=1000
com.solarmetric.kodo.ee.ManagedRuntimeProperties=TransactionManagerName=java:/TransactionManager
javax.jdo.PersistenceManagerFactoryClass=com.solarmetric.kodo.impl.jdbc.JDBCPersistenceManagerFactory
javax.jdo.option.ConnectionDriverName=org.gjt.mm.mysql.Driver
javax.jdo.option.ConnectionUserName=
javax.jdo.option.ConnectionPassword=
javax.jdo.option.ConnectionURL=jdbc:mysql://hostname/database?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true
javax.jdo.option.MinPool=0
javax.jdo.option.MaxPool=20
javax.jdo.option.Optimistic=true
javax.jdo.option.RetainValues=true
javax.jdo.option.NontransactionalRead=false
com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout=10
com.solarmetric.kodo.impl.jdbc.AutoReturnTimeout=10
com.solarmetric.kodo.impl.jdbc.DictionaryClass=com.solarmetric.kodo.impl.jdbc.schema.dict.MySQLDictionary
com.solarmetric.kodo.DataCacheProperties=Port=5555
Addresses=repository2.kl.ewarna.com:5555;repository.kl.ewarna.com:5555
CacheSize=5000
com.solarmetric.kodo.DataCacheClass=com.ewarna.pdm.sessions.PDMCache
=========== Stack Trace ================================
Communication link failure: java.io.IOException [code=0;state=08S01]
NestedThrowables:
com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
[SQL=SELECT t0.M_IDX, t3.JDOCLASSX, t3.JDOLOCKX, t3.M_CREATIONDATEX,
t3.M_DELETEDDATEX, t3.M_HOSTADDRESSX, t3.M_LASTMODIFIEDDATEX,
t3.M_NAMEX, t3.M_OLDIDX, t3.M_ID_M_OWNERX, t0.M_ID_M_ACCOUNTX,
t0.M_FULLNAMEX, t0.M_PASSWORDX, t0.M_PASSWORDEXPIRYDATEX, t3.M_NAMEX
>>>>FROM ABSTRACTENTITYX t2, ABSTRACTENTITYX t3, Accounts t1, Users t0 WHERE>>>>>>>((((((t2.M_NAMEX = 'development' AND t3.M_NAMEX = 'ewarna') AND>>>>(t3.M_DELETEDDATEX IS NULL)) AND (t2.M_DELETEDDATEX IS NULL)) AND>>>>(t3.M_DELETEDDATEX IS NULL)) AND t3.JDOCLASSX =>>>>'com.ewarna.pdm.entities.storage.UserPE') AND t0.M_IDX = t3.M_IDX AND>>>>t0.M_ID_M_ACCOUNTX = t1.M_IDX AND t1.M_IDX = t2.M_IDX) ORDER BY>>>>t3.M_NAMEX ASC
[PRE=SELECT t0.M_IDX, t3.JDOCLASSX, t3.JDOLOCKX, t3.M_CREATIONDATEX,
t3.M_DELETEDDATEX, t3.M_HOSTADDRESSX, t3.M_LASTMODIFIEDDATEX,
t3.M_NAMEX, t3.M_OLDIDX, t3.M_ID_M_OWNERX, t0.M_ID_M_ACCOUNTX,
t0.M_FULLNAMEX, t0.M_PASSWORDX, t0.M_PASSWORDEXPIRYDATEX, t3.M_NAMEX
>>>>FROM ABSTRACTENTITYX t2, ABSTRACTENTITYX t3, Accounts t1, Users t0 WHERE>>>>>>>((((((t2.M_NAMEX = ? AND t3.M_NAMEX = ?) AND (t3.M_DELETEDDATEX IS>>>>NULL)) AND (t2.M_DELETEDDATEX IS NULL)) AND (t3.M_DELETEDDATEX IS NULL))>>>>AND t3.JDOCLASSX = ?) AND t0.M_IDX = t3.M_IDX AND t0.M_ID_M_ACCOUNTX =>>>>t1.M_IDX AND t1.M_IDX = t2.M_IDX) ORDER BY t3.M_NAMEX ASC
Communication link failure: java.io.IOException
at
com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwDataStore(SQLExceptions.java:23)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCStoreManager.java:742)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java:92)
at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:792)
at
com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:137)
at
com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:65)
at com.ewarna.pdm.sessions.BasicQuery.getByFormula(BasicQuery.java:205)
at
com.ewarna.handlers.storage.SessionHandler$1.execute(SessionHandler.java:116)
at
com.ewarna.pdm.sessions.JDOCallBackExecutor.execute(JDOCallBackExecutor.java:40)
at
com.ewarna.handlers.storage.SessionHandler.login(SessionHandler.java:140)
at
com.ewarna.pdm.soap.AbstractSoapService.login(AbstractSoapService.java:44)
at
com.ewarna.pdm.soap.xfs.SoapServiceXFSImpl.login(SoapServiceXFSImpl.java:1199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.soap.server.RPCRouter.invoke(RPCRouter.java:146)
at
org.apache.soap.providers.RPCJavaProvider.invoke(RPCJavaProvider.java:129)
at
org.apache.soap.server.http.RPCRouterServlet.doPost(RPCRouterServlet.java:354)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:536)
NestedThrowablesStackTrace:
java.sql.SQLException: Communication link failure: java.io.IOException
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1606)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:886)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1809)
at
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1458)
at
com.solarmetric.datasource.PreparedStatementWrapper.executeQuery(PreparedStatementWrapper.java:93)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedQueryInternal(SQLExecutionManagerImpl.java:769)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeQueryInternal(SQLExecutionManagerImpl.java:692)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeQuery(SQLExecutionManagerImpl.java:373)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeQuery(SQLExecutionManagerImpl.java:357)
at
com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.selectPrimaryMappings(ClassMapping.java:1221)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCStoreManager.java:717)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java:92)
at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:792)
at
com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:137)
at
com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:65)
at com.ewarna.pdm.sessions.BasicQuery.getByFormula(BasicQuery.java:205)
at
com.ewarna.handlers.storage.SessionHandler$1.execute(SessionHandler.java:116)
at
com.ewarna.pdm.sessions.JDOCallBackExecutor.execute(JDOCallBackExecutor.java:40)
at
com.ewarna.handlers.storage.SessionHandler.login(SessionHandler.java:140)
at
com.ewarna.pdm.soap.AbstractSoapService.login(AbstractSoapService.java:44)
at
com.ewarna.pdm.soap.xfs.SoapServiceXFSImpl.login(SoapServiceXFSImpl.java:1199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.soap.server.RPCRouter.invoke(RPCRouter.java:146)
at
org.apache.soap.providers.RPCJavaProvider.invoke(RPCJavaProvider.java:129)
at
org.apache.soap.server.http.RPCRouterServlet.doPost(RPCRouterServlet.java:354)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:536)
Marc Prud'hommeaux wrote:
Makas-
Is Kodo idle during a long-running transaction, or does the error occur
when a new Connection is allocated? If the former, then there is nothing
we can do: MySQL shouldn't be dropping an open Connection while a
transaction is active. If the latter, then the property
com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout specified the
number of seconds between which the connection should be tested for
valididty when removed from the pool.
See also:
http://docs.solarmetric.com/manual.html#com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout
If this does not help, can you let us know your properties and some
details about your application?
In article <[email protected]>, Makas Tzavellas wrote:
Hi,
I'm using kodo 2.4.1 and the latest stable MySQL driver 3.0.6. After
leaving the application inactive for a few hours, the connection to
mysql is no longer usable. This did not occur with MySQL version 2.0.14
(as I believe Kodo weren't reusing the connections).
Are there any properties that I could set, so Kodo can keep the
connection active or recover from the problem?
Makas -
How to bound a JNDI reference to MySQL driver?
Hi.
Hi.
I am trying to write a simple J2EE application that would use Entety EJB with bean persisatance. I have downloaded driver from the www.mysql.org, copied it to the lib/system directory and modified J2EE_CLASSPATH in bin/userconfig.bat. I am using reference implementation server and with deploytool in �tools/serverconfiguration/datasourses/standard� I am specifying driver: org.gjt.mm.mysql.Driver or com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource and in datasourses in JNDI Name I write �jdbc/mydb� and in JDBC URL �jdbc:mysql://localhost:3306/this�, problem comes up when I try to reference �jdbc/mydb� from an entity bean, during deployment process of application it says that it is not bound
Binding name:`java:comp/env/jdbc\persondb`
Warning: Reference reference java:comp/env/jdbc\persondb is using a JNDI name that is not bound: jdbc\mydb
I do not get it, what I am doing wrong? Please help me to find out how to bind a JNDI name to MySQLHi! I had the same problem, too. I�m Brazilian and I�ve been learning the English language yet, but I�ll try to describe how to configure J2EE with MySQL.
I am using MySQL version 4.1.7 with J2EE version 1.3 on Windows XP Professional. The driver version of MySQL is 3.0.16.
You have to configure the following two files:
- <J2EE_HOME>\bin\setenv.bat
- <J2EE_HOME>\config\resource.properties
Do the following steps:
1) Copy the JAR file of MySQL driver (mysql-connector-java-3.0.16-ga-bin.jar) to <J2EE_HOME>\lib directory.
2) In <J2EE_HOME>\bin directory open the setenv.bat file and analize the code. It is not hard to understand the code, it is just the classpath configuration of J2EE. After understand it, add a reference of MySQL driver (mysql-connector-java-3.0.16-ga-bin.jar), that was copied to <J2EE_HOME>\lib directory.
3) Run the <J2EE_HOME>\bin\j2eeadmin.bat to configure the resource.properties file.There are two command lines to be executed, as below:
- j2eeadmin.bat -addJdbcDriver <CLASS NAME OF THE DRIVER>
- j2eeadmin.bat -addJdbcDatasource <JNDI NAME> <URL>
For example:
- j2eeadmin.bat -addJdbcDriver "com.mysql.jdbc.Driver"
- j2eeadmin.bat -addJdbcDatasource "jdbc/mysql/test" "jdbc:mysql://localhost/test?user=username&password=pass"
4) After run j2eeadmin.bat, the resource.properties file will be modified. But when I did it and when I executed the verbose command to start J2EE, some error messages was exhibited. So I decided to open the resource.properties file and I noticed that the character "\" was added erroneously in a lot of places of the code. It did not seem correct, so I decided to remove these characters replacing them. I was right! After I did it, I run verbose again and no more message error ocurred. I think it is a bug of J2EE.
Finish! I modified the datasource JNDI to access MySQL and then I run my EAR application. No problems occurred. My application is running succesfully.
Good luck! -
Problem with a j2se program and mysql driver
Hi,
We are developing an application which needs accessing to a mysql database. I have packed the application in a .jar. and inside the jar I have created a folder lib. And inside that folder I have put mysql driver.
As the same way, I have been reading in SDN forum, I have edited manifiest file and I have writen this:
Manifest-Version: 1.0
Sealed: true
Class-Path: lib/mysql-connector-java-5.0.4-bin.jar
Main-Class: package1.Main
When I introduce this command java -jar program1.jar, the jvm says this:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
I know when I use java -jar, classpath system variable doesn't mind. But even this variable is set up properly. If you could help me it would be great. I'm getting stuck with this.
Thanks in advance.@CiMaBuE wrote:
Hi,
We are developing an application which needs accessing to a mysql database. I have packed the application in a .jar. and inside the jar I have created a folder lib. And inside that folder I have put mysql driver.That's the problem. JARs don't look inside themselves for 3rd party JARs. That /lib directory needs to be relative to the program1.jar that you created.
I believe modules or OSGi are supposed to address this, but executable JARs do not today.
% -
import java.sql.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class receiving extends Applet implements ItemListener, ActionListener
Connection conDatabase;//door to the database
Statement cmdDatabase;//messenger
ResultSet rsDatabase;//bucket
private String dbURL = "jdbc:mysql://web6.duc.auburn.edu/?user=gunthms&password=tigers05";
boolean blnSuccessfulOpen = false;
Choice Order_No = new Choice();
TextField txtOrder_No = new TextField(6);
TextField txtCompany = new TextField(20);
TextField txtLocation = new TextField(20);
TextField txtDate_Shipped = new TextField(10);
TextField txtBlack_Poly = new TextField(8);
TextField txtBlue_Poly = new TextField(8);
TextField txtBrass1 = new TextField(8);
TextField txtBrass2 = new TextField(8);
TextField txtTransaction_No = new TextField(8);
TextField txtTracking_No = new TextField(18);
Button btnAdd = new Button("Add");
Button btnEdit = new Button("Save");
Button btnCancel = new Button("Cancel");
Button btnDelete = new Button("Delete");
Button btnNext = new Button(" > ");
Button btnLast = new Button(" >>> ");
Button btnPrevious = new Button(" < ");
Button btnFirst = new Button(" <<< ");
public void init()
//Set up panel and load database
LoadDatabase();
if (blnSuccessfulOpen)
Order_No.insert("Select an Order",0);
add(Order_No);
add(new Label(" "));
Order_No.addItemListener(this);
add(new Label("Order No"));
add(txtOrder_No);
add(new Label("Company"));
add(txtCompany);
add(new Label("Location"));
add(txtLocation);
add(new Label(" "));
add(new Label("Date Shipped"));
add(txtDate_Shipped);
add(new Label(" "));
add(new Label("Black Poly (sqft)"));
add(txtBlack_Poly);
add(new Label("Blue Poly (sqft)"));
add(txtBlue_Poly);
add(new Label("Brass 1inch (pcs)"));
add(txtBrass1);
add(new Label("Brass 2inch (pcs)"));
add(txtBrass2);
add(new Label(" "));
add(new Label("Transaction No"));
add(txtTransaction_No);
add(new Label(" "));
add(new Label("Tracking No"));
add(txtTracking_No);
setTextToNotEditable();
add(new Label(" "));
add(btnAdd);
btnAdd.addActionListener(this);
add(btnEdit);
btnEdit.addActionListener(this);
add(btnDelete);
btnDelete.addActionListener(this);
add(btnCancel);
btnCancel.addActionListener(this);
btnCancel.setEnabled(false);
//Navigate Buttons
add(btnFirst);
btnFirst.addActionListener(this);
add(btnPrevious);
btnPrevious.addActionListener(this);
add(btnNext);
btnNext.addActionListener(this);
add(btnLast);
btnLast.addActionListener(this);
else
System.err.println("Unable to populate fields");
public void LoadDatabase()
try
//Load MySQL drivers
Class.forName("org.gjt.mm.mysql.Driver");
catch ( java.lang.ClassNotFoundException e )
System.err.println("MySQL ORG Package Driver not found ...");
System.err.println(e.getMessage());
/* try
//Load MySQL drivers
Class.forName("com.mysql.jdbc.Driver");
catch ( java.lang.ClassNotFoundException e )
System.err.println("MySQL COM Package Driver not found ...");
System.err.println(e.getMessage());
try
//Connect to the database
conDatabase = DriverManager.getConnection(dbURL);
catch(SQLException error)
System.err.println("Unable to Connect to Database");
try
Statement cmdDatabase = conDatabase.createStatement();
//Create the ResultSet
rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING;");
loadNumbers(rsDatabase);
blnSuccessfulOpen = true;
catch(SQLException error)
System.err.println("Error in recordset");
public void loadNumbers(ResultSet rsDatabase)
//Fill last name list box
try
while(rsDatabase.next())
Order_No.add(rsDatabase.getString("Order_No"));
catch (SQLException error)
System.err.println("Error in Display Record");
public void itemStateChanged(ItemEvent event)
//Retrieve and display the selected record
String strOrder_No = Order_No.getSelectedItem();
showStatus(""); //Delete instructions
try
Statement cmdDatabase = conDatabase.createStatement();
rsDatabase = cmdDatabase.executeQuery(
"Select * from gunthmsjv.RECEIVING where Order_No = '" + strOrder_No + "';");
txtOrder_No.setText(strOrder_No);
displayRecord(rsDatabase);
setTextToEditable();
catch(SQLException error)
showStatus("Error in recordset");
public void displayRecord(ResultSet rsDatabase)
//Display the current record
try
if(rsDatabase.next())
txtOrder_No.setText(rsDatabase.getString("Order_No"));
txtCompany.setText(rsDatabase.getString("Company"));
txtLocation.setText(rsDatabase.getString("Location"));
txtDate_Shipped.setText(rsDatabase.getString("Date_Shipped"));
txtBlack_Poly.setText(rsDatabase.getString("Black_Poly"));
txtBlue_Poly.setText(rsDatabase.getString("Blue_Poly"));
txtBrass1.setText(rsDatabase.getString("Brass1"));
txtBrass2.setText(rsDatabase.getString("Brass2"));
txtTransaction_No.setText(rsDatabase.getString("Transaction_No"));
txtTracking_No.setText(rsDatabase.getString("Tracking_No"));
showStatus("");
else
showStatus("Record not found");
ClearTextFields();
catch (SQLException error)
showStatus("Error in display record");
public void actionPerformed(ActionEvent event)
//Test the command buttons
Object objSource = event.getSource();
if(objSource == btnAdd && event.getActionCommand() == "Add")
Add();
else if (objSource == btnAdd)
Save();
else if(objSource == btnEdit)
Edit();
else if(objSource == btnDelete)
Delete();
else if(objSource == btnCancel)
Cancel();
else if(objSource == btnFirst)
firstRecord();
else if(objSource == btnNext)
nextRecord();
else if(objSource == btnPrevious)
previousRecord();
else if(objSource == btnLast)
lastRecord();
public void setTextToNotEditable()
//Lock the text fields
txtOrder_No.setEditable(false);
txtCompany.setEditable(false);
txtLocation.setEditable(false);
txtDate_Shipped.setEditable(false);
txtBlack_Poly.setEditable(false);
txtBlue_Poly.setEditable(false);
txtBrass1.setEditable(false);
txtBrass2.setEditable(false);
txtTransaction_No.setEditable(false);
txtTracking_No.setEditable(false);
public void setTextToEditable()
//Unlock the text fields
txtOrder_No.setEditable(true);
txtCompany.setEditable(true);
txtLocation.setEditable(true);
txtDate_Shipped.setEditable(true);
txtBlack_Poly.setEditable(true);
txtBlue_Poly.setEditable(true);
txtBrass1.setEditable(true);
txtBrass2.setEditable(true);
txtTransaction_No.setEditable(true);
txtTracking_No.setEditable(true);
public void ClearTextFields()
//Clear the Text Fields
txtOrder_No.setText("");
txtCompany.setText("");
txtLocation.setText("");
txtDate_Shipped.setText("");
txtBlack_Poly.setText("");
txtBlue_Poly.setText("");
txtBrass1.setText("");
txtBrass2.setText("");
txtTransaction_No.setText("");
txtTracking_No.setText("");
public void Add()
//Add a new record
showStatus("");
//Empty the text fields
setTextToEditable();
ClearTextFields();
txtOrder_No.requestFocus ();
//Change the button labels
btnAdd.setLabel("OK");
btnCancel.setEnabled(true);
//Disable the Delete and Edit buttons
btnDelete.setEnabled(false);
btnEdit.setEnabled(false);
public void Save()
//Save the new record
// Activated when Add button has an "OK" label
if (txtOrder_No.getText().length() == 0 && txtLocation.getText().length() == 0)
showStatus("The Customer Name or ID Number is blank");
else
try
Statement cmdDatabase = conDatabase.createStatement();
cmdDatabase.executeUpdate(
"Insert Into gunthmsjv.RECEIVING "
+ "(Order_No,Company,Location,Date_Shipped,Black_Poly,Blue_Poly,Brass1,Brass2,Transaction_No,txtTracking_No) "
+ "Values('"
+ txtOrder_No.getText() + "', '"
+ txtCompany.getText() + "', '"
+ txtLocation.getText() + "', '"
+ txtDate_Shipped.getText() + "', '"
+ txtBlack_Poly.getText() + "', '"
+ txtBlue_Poly.getText() + "', '"
+ txtBrass1.getText() + "', '"
+ txtBrass2.getText() + "', '"
+ txtTransaction_No.getText() + "', '"
+ txtTracking_No.getText() + "')");
//Add to name list
Order_No.add(txtOrder_No.getText());
//Reset buttons
Cancel();
catch(SQLException error)
showStatus("Error: " + error.toString());
public void Delete()
//Delete the current record
int intIndex = Order_No.getSelectedIndex();
String strOrder_No = Order_No.getSelectedItem();
if(intIndex == 0) //Make sure a record is selected
//Position zero holds a message
showStatus("Please select the record to be deleted");
else
try
//Delete from Database
Statement cmdDatabase = conDatabase.createStatement();
cmdDatabase.executeUpdate(
"Delete from gunthmsjv.RECEIVING where Order_No = '"
+ strOrder_No + "';");
ClearTextFields(); //Delete from screen
Order_No.remove(intIndex); //Delete from list
showStatus("Record deleted"); //Display message
catch(SQLException error)
showStatus("Error during Delete");
public void Cancel()
//Enable the Delete and Edit buttons
btnDelete.setEnabled(true);
btnEdit.setEnabled(true);
btnCancel.setEnabled(false);
//Change caption of button
btnAdd.setLabel("Add");
//Clear the text fields and status bar
ClearTextFields();
showStatus("");
public void Edit()
//Save the modified record
int intIndex = Order_No.getSelectedIndex();
if(intIndex == 0) //Make sure a record is selected
//Position zero holds a message
showStatus("Please select the record to be changed");
else
String strOrder_No = Order_No.getSelectedItem();
try
Statement cmdDatabase = conDatabase.createStatement();
cmdDatabase.executeUpdate(
"Update gunthmsjv.RECEIVING "
+ "Set Order_No = '" + txtOrder_No.getText() + "', "
+ "Company = '" + txtCompany.getText() + "', "
+ "Location = '" + txtLocation.getText() + "', "
+ "Date_Shipped = '" + txtDate_Shipped.getText() + "', "
+ "Black_Poly = '" + txtBlack_Poly.getText() + "', "
+ "Blue_Poly = '" + txtBlue_Poly.getText() + "', "
+ "Brass1 = '" + txtBrass1.getText() + "', "
+ "Brass2 = '" + txtBrass2.getText() + "', "
+ "Transaction_No = '" + txtTransaction_No.getText() + "', "
+ "txtTracking_No = '" + txtTracking_No.getText() + "', ");
if (!strOrder_No.equals(txtOrder_No.getText()))
//Last name changed; change the list
Order_No.remove(intIndex); //Remove the old entry
Order_No.add(txtOrder_No.getText()); //Add the new entry
catch(SQLException error)
showStatus("Error during Edit");
public void stop()
//Terminate the connection
try
if (conDatabase != null)
conDatabase.close();
catch(SQLException error)
showStatus("Unable to disconnect");
public void firstRecord()
int first = 1;
Order_No.select(first);
String strNewOrder_No = Order_No.getSelectedItem();
try
Statement cmdDatabase = conDatabase.createStatement();
rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
txtOrder_No.setText(strNewOrder_No);
displayRecord(rsDatabase);
catch(SQLException error)
showStatus("item state try.");
public void previousRecord()
int PreviousIndex = 0;
PreviousIndex = Order_No.getSelectedIndex();
PreviousIndex--;
if (PreviousIndex > 0)
Order_No.select(PreviousIndex);
String strNewOrder_No = Order_No.getSelectedItem();
try
Statement cmdDatabase = conDatabase.createStatement();
rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
txtOrder_No.setText(strNewOrder_No);
displayRecord(rsDatabase);
catch(SQLException error)
showStatus("item state try.");
else
showStatus("You've reached the beginning of the list.");
public void nextRecord()
int NextIndex = 0;
NextIndex = Order_No.getSelectedIndex();
if(NextIndex == 0)
NextIndex = 1;
else
NextIndex++;
if (NextIndex < Order_No.getItemCount())
Order_No.select(NextIndex);
String strNewOrder_No = Order_No.getSelectedItem();
try
Statement cmdDatabase = conDatabase.createStatement();
rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
txtOrder_No.setText(strNewOrder_No);
displayRecord(rsDatabase);
catch(SQLException error)
showStatus("item state try.");
else
showStatus("You've reached the end of the list.");
public void lastRecord()
int last = 0;
while (last < Order_No.getItemCount()-1)
last++;
Order_No.select(last);
String strNewOrder_No = Order_No.getSelectedItem();
try
Statement cmdDatabase = conDatabase.createStatement();
rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
txtOrder_No.setText(strNewOrder_No);
displayRecord(rsDatabase);
catch(SQLException error)
showStatus("item state try.");
How do I point the class.forname to a url? This class will be run off a webserver with an html file. Everytime I run it currently, it comes back with a NullPointerException so I know it can't find it. I know if I run it locally, the file runs properly... Can someone help ASAP :(oad: class http://www.auburn.edu/~gunthms/classes/shipping.class not found.
java.lang.ClassNotFoundException: http:..www.auburn.edu.~gunthms.classes.shipping.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.UnknownHostException: www
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.plugin.net.protocol.http.HttpClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.plugin.net.protocol.http.HttpClient.<init>(Unknown Source)
at sun.plugin.net.protocol.http.HttpClient.New(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.createConnection(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
It's just not finding it. Now if there were a way of loading that class from a jar file... or just any method at all of loading that... I think it would work... thanks alot man for your continuing help. -
Cannot load JDBC driver class 'org.gjt.mm.mysql.Driver'
Hi,
I'm trying to run my web app and connect to a MySQL database but keep getting this error:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.gjt.mm.mysql.Driver'
any ideas?
Thanks!Lookup the stacktrace and find the root cause of the exception.
My cents on a ClassNotFoundException which is rather self-explaining.
By the way, the mentioned driver class name is a very old driver. You shouldn't be using that anymore. Surf to the MySQL homepage and download the most recent Connector/J JDBC driver for your database version. Documentation is also available over there. -
Hi,
I am a new user in this forum..
I have just installed tomcat and mysql and jdbc fresh on my new system..
first of all here is what i have done...
i have installed mysql integrated in xampp at c:\xampp\mysql
i have installed my tomcat at C:\Programme\Apache Software Foundation\Tomcat 5.5
i have put jdbc <dirver>.jar file copied in all sorts of directories like ....
<tomcat_home>\common\lib
<tomcat_home>\webapps\axis\WEB-INF\lib\ext
<java_home>\lib
<java_home>\jre\lib\ext
my calsspath looks something like this
.;C:\Programme\QuickTime\QTSystem\QTJava.zip;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\mysql-connector-java-5.0.6-bin.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\webapps\axis\WEB-INF\lib\mysql-connector-java-5.0.6-bin.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\servlet-api.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\jsp-api.jar;C:\Programme\Java\jdk1.5.0_05\jre\lib\ext\mysql-connector-java-5.0.6-bin.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\activation.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis-ant.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\jaxrpc.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\mail.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\saaj.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\mysql-connector-java-5.0.6-bin.jar
which is basically all the jar files in the web-inf\lib folder and references to all the copies of driver as mentioned before
these are results of a lot of desperatio but still the code which i run....
package mypackage;
import java.sql.*;
public class JDBCConnector
public static void main(String[] arg) throws Exception
System.out.println("Initiating Database Mysql Connection");
//try {
Statement stmt;
// Register the JDBC driver for MySQL.
Class.forName("org.gjt.mm.mysql.Driver ").newInstance();
// Define URL of database server for
// database named mysql on the localhost
// with the default port number 3306.
String url = "jdbc:mysql://wifh-1.fhso.ch:3306/";
// Get a connection to the database for a
// user named root with a blank password.
// This user is the default administrator
// having full privileges to do anything.
Connection con = DriverManager.getConnection(url,"root", "birnExy");
//Display URL and connection information
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
//Get a Statement object
stmt = con.createStatement();
// Create the new database
stmt.executeUpdate("CREATE DATABASE JunkDB3");
//Register a new user named auser on the
// database named JunkDB with a password
// drowssap enabling several different
// privileges.
stmt.executeUpdate("GRANT SELECT,INSERT,UPDATE,DELETE," +"CREATE,DROP " +"ON JunkDB3.* TO 'nishant'@'localhost' " +"IDENTIFIED BY 'nishant';");
con.close();
//}catch( Exception e ) {
// e.printStackTrace();
//}//end catch
//return hook;
}//end main
}//end class JDBCConnector
gives the following error.....
<soapenv:Envelope>
−
<soapenv:Body>
−
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
−
<faultstring>
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
</faultstring>
−
<detail>
<ns1:hostname>SADMC0087</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
please help me20.05.2007 22:43:26 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programme\Java\jdk1.5.0_05\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\QuickTime\QTSystem\;C:\Programme\ATI Technologies\ATI Control Panel;C:\Programme\Java\jdk1.5.0_05\bin;C:\Programme\Apache Software Foundation\Tomcat 5.5\common\lib;
20.05.2007 22:43:27 org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
20.05.2007 22:43:27 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1203 ms
20.05.2007 22:43:27 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
20.05.2007 22:43:27 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.23
20.05.2007 22:43:27 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
20.05.2007 22:43:28 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive SIpages.war
20.05.2007 22:43:31 org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
20.05.2007 22:43:31 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
20.05.2007 22:43:31 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/109 config=null
20.05.2007 22:43:31 org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
20.05.2007 22:43:32 org.apache.catalina.startup.Catalina start
INFO: Server startup in 4813 ms
now this is when i run from eclipse where SIpages.war is my war file to be deployed...which looks something like this
sipages/web-inf/classes
sipages/web-inf/src
sipages/web-inf/lib-this has the jar file as you mentioned
and come other files...nwo where soes my .java file go in this war and how do i compile the java file -
Driver class 'org.gjt.mm.mysql.Driver' not Found JSP
OS ->Windows XP Pro
Tomcat version ->4.0.1
jdk version -> 1.3.1
database -> mysql
Classpath = .;C:\jakarta-tomcat-4.0.1\common\lib\servlet.jar;C:\jakarta-tomcat-4.0.1\common\lib\mm.mysql.jdbc-1.2c\mysql_uncomp.jar;
I am trying to run a function in a javabean to startup up a connection to a database. Code as follows...
public void connect() throws ClassNotFoundException,
SQLException,
Exception {
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
con = DriverManager.getConnection(
"jdbc:mysql://localhost/Wrox ?user=root&password=lunchbox ");
} catch (ClassNotFoundException cnfe) {
error = "ClassNotFoundException: Could not locate DB driver.";
throw new ClassNotFoundException(error);
} catch (SQLException cnfe) {
error = "SQLException: Could not connect to database.";
throw new SQLException(error);
} catch (Exception e) {
error = "Exception: An unknown error occurred while connecting " +
"to database.";
throw new Exception(error);
I call it from my jsp page code as follows.. connect in bold
<%@ page language="java"
import="java.sql.*, java.io.*, java.util.*, com.wrox.databases.*"
errorPage="error.jsp" %>
<jsp:useBean id="book" class="com.wrox.databases.Books" />
<html>
<head>
<title> Wrox Press Ltd. </title>
</head>
<body>
<h1> Wrox Press Ltd.</h1>
<h2> List of Books </h2>
<b>Add More Books</b>
<form action="delete.jsp" method="post">
<table border="1">
<tr>
<td><b>ID:</b></td>
<td><B>Title:</b></td>
<td><B>Price:</b></td>
</tr>
<%
book.connect();
ResultSet rs = book.viewBooks();
while (rs.next()) {
%>
<tr>
<td>
<input type="checkbox" name="pkey"
value="<%= rs.getString("Title_ID") %>" />
</td>
<td><%= rs.getString("Title") %></td>
<td><%= rs.getString("Price") %></td>
</tr>
<%
%>
</table>
Check books for deletion.<BR>
<input type="submit" value="Delete All Checked Books">
</form>
<% book.disconnect(); %>
</body>
</html>
The name of the bean is correct and so is the package it is stored under. I tried it in the bean and got "ClassNotFoundException" Could not locate DB driver". I tried it with DBtags and got
Driver class 'org.gjt.mm.mysql.Driver' not Found
any help would be really appreciated.When using any 3rd party library with tomcat. the jar file of that library has to be put in the WEB-INF/lib directory of your application. Then only tomcat will find it.
So the my-sql driver would have come in a jar file. just put that jar file in the WEB-INF/lib directory.
After that things should work. If they don't please post again.
hope this helps.
regards,
Abhishek.
Maybe you are looking for
-
Payment terms in Customer Master
Hi, In Customer Master,we have payment terms field in Company Code View and Sales Area View.What is the difference between them.If i maintain different payments in those views,which has the highest priority. Vinu
-
I have a 20" duo-core imac (white) at work and a 20" duo-core (aluminum) at home and have the same issue on both machines where the screen will dim if the computer is inactive for a brief period. Its not that the computer is going to sleep with the s
-
Why does my FT freezes when it starts? or simply wont process the call?
why does my FT freezes when it starts? or simply wont process the call? Facetime really *****...!
-
What song are you listening to now?
I have Pandora playing....and a Carrie Underwood song just came on. Called "The more boys I meet". It says....the more boys I meet, the more I love my dog. That made me lol! Dorothy|Social Media Supervisor | Best Buy® Corporate Private Message
-
Connect Sql express with studio
1>I have downloaded the sqlservers jar file placed it in lib folder I am using netbeans i am now attaching the Sql database created under windows Authentecation to netbeans. I don't know how to set the connection Syntax.Even when i tried to create ne