JDBC for MySQL + TOMCAT
Anybody knows how to configure the JDBC + TOMCAT?
try to install mysql-connector-java into java home
directory. and specify the path in classpath.
had i answered ur question correctly.No JARs belong in JAVA_HOME.
Tomcat ignores your system CLASSPATH.
This advice is utterly, completely wrong. It's not even wrong.
Put the MySQL JAR in your app's WEB-INF/lib directory, then learn to configure a JNDI data source.
%
Similar Messages
-
I want to connect to MySql Database. My program Source is :
import java.sql.*;
@SuppressWarnings({"ALL"})
public class test {
public static void main(String args[]) throws ClassNotFoundException, SQLException, IllegalAccessException, InstantiationException {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con = DriverManager.getConnection ("jdbc:odbc:mysql://127.0.0.1:3306, "root", "edlovema1017");
Statement stmt = con.createStatement();
stmt.executeUpdate("DROP TABLE users");
There is an error when my program is running.
this error :
Exception in thread "main" java.lang.NullPointerException
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:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)1) How do you compile that?
in
getConnection ("jdbc:odbc:mysql://127.0.0.1:3306, "root", "edlovema1017");closing " is missing for the first parameter
2) why jdbc:odbc:mysql not just jdbc:mysql ?
3) as sabre150 stated, use
Class.forName("com.mysql.jdbc.Driver")instead of
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();4) NEVER leave connection opened - add con.close() at the end
5) Specify the database name, e.g.
getConnection ("jdbc:mysql://127.0.0.1:3306/mydb", "root", "edlovema1017");6) good luck -
Has anyone run the connection pooling for mysql & tomcat successfully?
I'm trying to set up connection pooling. I'm following the how-to page at
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
But when i test the DBTest/test.jsp file, tomcat displays an error =
could not load jdbc driver class 'null'(msdos)
i have placed all the required .jar files in the tomcat lib.
below is the cofiguration i did to the server.xml file
<!-- Example Server Configuration File -->
<!-- Note that component elements are nested corresponding to their
parent-child relationships with each other -->
<!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port.
Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Uncomment these entries to enable JMX MBeans support -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required.
Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Tomcat-Standalone">
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Each Connector passes requests on to the
associated "Container" (normally an Engine) for processing.
By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
You can also enable an SSL HTTP/1.1 Connector on port 8443 by
following the instructions below and uncommenting the second Connector
entry. SSL support requires the following steps (see the SSL Config
HOWTO in the Tomcat 4.0 documentation bundle for more detailed
instructions):
* Download and install JSSE 1.0.2 or later, and put the JAR files
into "$JAVA_HOME/jre/lib/ext".
* Execute:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
with a password value of "changeit" for both the certificate and
the keystore itself.
By default, DNS lookups are enabled when a web application calls
request.getRemoteHost(). This can have an adverse impact on
performance, so you can disable it by setting the
"enableLookups" attribute to "false". When DNS lookups are disabled,
request.getRemoteHost() will return the String version of the
IP address of the remote client.
-->
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8081 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to -1 -->
<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true"
acceptCount="100" debug="0" scheme="https" secure="true"
useURIValidationHack="false" disableUploadTimeout="true">
<Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory"
clientAuth="false" protocol="TLS" />
</Connector>
-->
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
-->
<!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
<!-- See proxy documentation for more information about using this. -->
<!--
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8082" minProcessors="5" maxProcessors="75"
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" debug="0" connectionTimeout="20000"
proxyPort="80" useURIValidationHack="false" />
-->
<!-- Define a non-SSL legacy HTTP/1.1 Test Connector on port 8083 -->
<!--
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8083" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" />
-->
<!-- Define a non-SSL HTTP/1.0 Test Connector on port 8084 -->
<!--
<Connector className="org.apache.catalina.connector.http10.HttpConnector"
port="8084" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host). -->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Standalone" defaultHost="localhost" debug="0">
<!-- The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
headers and cookies that were sent, for all requests received by
this instance of Tomcat. If you care only about requests to a
particular virtual host, or a particular application, nest this
element inside the corresponding <Host> or <Context> entry instead.
For a similar mechanism that is portable to all Servlet 2.3
containers, check out the "RequestDumperFilter" Filter in the
example application (the source for this filter may be found in
"$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
Request dumping is disabled by default. Uncomment the following
element to enable it. -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally -->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<!-- Comment out the old realm but leave here for now in case we
need to go back quickly -->
<!--
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/authority"
connectionName="test" connectionPassword="test"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
connectionName="scott" connectionPassword="tiger"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL="jdbc:odbc:CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="/my-jsp" docBase="c:\JSP-Files" debug="0"
privileged="true" reloadable="true" />
<Context path="" docBase="c:\Inetpub\wwwroot" debug="0" privileged="true" />
<Context path="/sharon" docBase="C:\Tomcat 4.1\webapps\sharon" debug="0" privileged="true" />
<!-- Normally, users must authenticate themselves to each web app
individually. Uncomment the following entry if you would like
a user to be authenticated the first time they encounter a
resource protected by a security constraint, and then have that
user identity maintained across all web applications contained
in this virtual host. -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn"
debug="0"/>
-->
<!-- Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
-->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<!-- Logger shared by all Contexts related to this virtual host. By
default (when using FileLogger), log files are created in the "logs"
directory relative to $CATALINA_HOME. If you wish, you can specify
a different directory with the "directory" attribute. Specify either a
relative (to $CATALINA_HOME) or absolute path to the desired
directory.-->
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<!-- Define properties for each web application. This is only needed
if you want to set non-default properties, or have web application
document roots in places other than the virtual host's appBase
directory. -->
<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->
<!-- Tomcat Examples Context -->
<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity"
home="com.wombat.empl.EmployeeRecordHome"
remote="com.wombat.empl.EmployeeRecord"/>
<!-- If you wanted the examples app to be able to edit the
user database, you would uncomment the following entry.
Of course, you would want to enable security on the
application as well, so this is not done by default!
The database object could be accessed like this:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
UserDatabase database =
(UserDatabase) envCtx.lookup("userDatabase");
-->
<!--
<ResourceLink name="userDatabase" global="UserDatabase"
type="org.apache.catalina.UserDatabase"/>
-->
<!-- PersistentManager: Uncomment the section below to test Persistent
Sessions.
saveOnRestart: If true, all active sessions will be saved
to the Store when Catalina is shutdown, regardless of
other settings. All Sessions found in the Store will be
loaded on startup. Sessions past their expiration are
ignored in both cases.
maxActiveSessions: If 0 or greater, having too many active
sessions will result in some being swapped out. minIdleSwap
limits this. -1 means unlimited sessions are allowed.
0 means sessions will almost always be swapped out after
use - this will be noticeably slow for your users.
minIdleSwap: Sessions must be idle for at least this long
(in seconds) before they will be swapped out due to
maxActiveSessions. This avoids thrashing when the site is
highly active. -1 or 0 means there is no minimum - sessions
can be swapped out at any time.
maxIdleSwap: Sessions will be swapped out if idle for this
long (in seconds). If minIdleSwap is higher, then it will
override this. This isn't exact: it is checked periodically.
-1 means sessions won't be swapped out for this reason,
although they may be swapped out for maxActiveSessions.
If set to >= 0, guarantees that all sessions found in the
Store will be loaded on startup.
maxIdleBackup: Sessions will be backed up (saved to the Store,
but left in active memory) if idle for this long (in seconds),
and all sessions found in the Store will be loaded on startup.
If set to -1 sessions will not be backed up, 0 means they
should be backed up shortly after being used.
To clear sessions from the Store, set maxActiveSessions, maxIdleSwap,
and minIdleBackup all to -1, saveOnRestart to false, then restart
Catalina.
-->
<!--
<Manager className="org.apache.catalina.session.PersistentManager"
debug="0"
saveOnRestart="true"
maxActiveSessions="-1"
minIdleSwap="-1"
maxIdleSwap="-1"
maxIdleBackup="-1">
<Store className="org.apache.catalina.session.FileStore"/>
</Manager>
-->
<Environment name="maxExemptions" type="java.lang.Integer"
value="15"/>
<Parameter name="context.param.name" value="context.param.value"
override="false"/>
<Resource name="jdbc/EmployeeAppDb" auth="SERVLET"
type="javax.sql.DataSource"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>user</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javadude</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
</ResourceParams>
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
<ResourceLink name="linkToGlobalResource"
global="simpleValue"
type="java.lang.Integer"/>
</Context>
</Host>
</Engine>
</Service>
<!-- The MOD_WEBAPP connector is used to connect Apache 1.3 with Tomcat 4.0
as its servlet container. Please read the README.txt file coming with
the WebApp Module distribution on how to build it.
(Or check out the "jakarta-tomcat-connectors/webapp" CVS repository)
To configure the Apache side, you must ensure that you have the
"ServerName" and "Port" directives defined in "httpd.conf". Then,
lines like these to the bottom of your "httpd.conf" file:
LoadModule webapp_module libexec/mod_webapp.so
WebAppConnection warpConnection warp localhost:8008
WebAppDeploy examples warpConnection /examples/
The next time you restart Apache (after restarting Tomcat, if needed)
the connection will be established, and all applications you make
visible via "WebAppDeploy" directives can be accessed through Apache.
-->
<!-- Define an Apache-Connector Service -->
<!--
<Service name="Tomcat-Apache">
<Connector className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>
<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>
<Realm className="org.apache.catalina.realm.MemoryRealm" />
</Engine>
</Service>
-->
</Server>
Pleas4 help!!!you have your driver jar in Tomcat\common\lib?
if so, check your classpath, it could be that. -
Any Good link for mysql Installation in solaris 10?
Please share with me good link for mysql, Tomcat installation(latest version)
I found http://instmysql5sol10.blogspot.com/ in internet but not able to download "Download the packages (both Standard and Max) and save them in an appropriate directory".alan.pae wrote:
attempted to install Solaris on it. Everything goes OK but I am confused by an info message that I get upon booting the system from CD:
SunOS Release 5.10 Version Generic_137138-09 *32-bit* You got it installed and then you booted from the CD???
If you booted from the hard disk then run:
isainfo -kv
alanNo, of course not. It isn't installed yet. I meant that I booted the
computer from from the install DVD to start the installation process.
But thanks for the info. I'll install it and will run this command. -
Stored procedure : how to call SP in sender JDBC adapter for mysql
HI friends ,
we have JDBC---->XI--
>SAP scenario. For some business requirement, we have to call STORED PROCEDURE , please let me know how to call SP in sender JDBC adapter for mysql .
Thanks
mojibHi Mojib,
Please create a sample stored procedure like this which contains select statement and in communication channel give
wite stored procedure name only to sql query statment and in update statement write <test>.
I am executing this stored procedure successfully.
Create Proc GetResultX As
Begin
Select * From TESTX
End
Execute statement for stored procedure is :
Exec GetResultX
Regards
Laxmi Bhushan Jha
Rewards point if found usful
I have given same answer to one of the same thread -
Problem with JDBC driver for mysql
I have downloaded the Connector/J3.0 mysql-connector-java-3.0.7-stable.tar.gz from www.mysql.com/downloads/api-jdbc-stable.html web site and used gunzip and tar to extract the file. I have received the following error message:
tar: directory checksum error
Will this error cause some problem later on?
Which directory should I put the driver into? Can I put it in any directory?
Do I need to set the classpath for the driver? If yes, how can I set it?
What is the connect string? Can you give a sample for me? I am using Solaris 5.8 and mysql is on the same machine.
Thanks a lot,
Lisathis is an example of a connect string for mysql that i used...
public Connection CreateConnection () throws Exception
Connection myConn = null;
String driverName = "org.gjt.mm.mysql.Driver";
String dbUrl = "jdbc:mysql://www.desres.com/jhazrd?user=jhazrd&password=????";
Class.forName(driverName);
myConn = DriverManager.getConnection (dbUrl);
return myConn;
} -
Need JDBC driver string for MYSQL DB Resin server
Please any body provide me the jdbc driver for MYSQL
database for Resin server
ThanksThe driver and URL string are independent of server you deploy them on.
Put that JDBC JAR in your Web app's WEB-INF/lib directory and it'll be in the CLASSPATH.
Set up the pooled data source as appropriate for your server. That's the server-dependent part.
% -
The mysteries of JDBC, JNDI, and Tomcat 5.5.4
Like thousands beforefore, I can't get connection pooling to work in Tomcat. I followed all the steps:
- put jar file for MySQL JDBC driver in TOMCAT_HOME/common/lib
- put the Jakarta Commons libs in the same location
- put resource declaration in META-INF/context.xml, per the Tomcat 5.5 docs like so:
<Context docbase="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\commutercorps"
path="\commutercorps" >
<Resource name="jdbc/commutercorpsds"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="myusername"
password="mypassword"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/commuter_corps_signup"/>
</Context>- added resource ref in web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/commutercorpsds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>I also double checked my connection URL and found that it does work fine when do this in my Java code:
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection
("jdbc:mysql://localhost:3306/commuter_corps_signup", "...", "...");When I try to use Tomcat 5.5.4, JNDI like this...
try
InitialContext initialContext = new InitialContext();
DataSource dataSource =
(DataSource) initialContext.lookup
("java:comp/env/jdbc/commutercorpsds");
Connection con = dataSource.getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate(SQLMaker.getInsert(request,
request.getParameter("table")));
con.close();
stmt.close();
} catch (NamingException e)
System.out.println(e.getMessage());
e.printStackTrace();
}...I get...
Cannot create JDBC driver of class '' for connect URL 'null'
Caused by: java.sql.SQLException: No suitable driver
Any help would be greatly appreciated.
Thanks,
EI used to get the message
Cannot create JDBC driver of class '' for
connect URL 'null'
No suitable driverError.
I was running, jakarta-tomcat-5.0.14.exe on windows.
I had it installed on a path without spaces
d:\tomcat5\Good.
I wanted to use Hibernate. So i used, extensiontools.What's that?
First create a env var: HIBERNATE_HOME pointing to
the hibernate extracted dir.No need for this.
Modify setenv.bat to correct %CP% for
commons-logging, commons-collection and anything
else: the version string at the end of the jar
changes.Wrong. You shouldn't be doing this.
Then run ddl2hbm, straightforward, fill info in all
tabs and hit generate. Will show some error message,
but still creates xmls.I don't see what any of this has to do with Tomcat deployment.
Then run hbm2java, and hand over each xml file as
parameter. Creates some java files in generated dir.
Modify the toString method to something simpler and
remove the import for apache class.All great, but still has nothing to do with Tomcat deployment.
move them over to webapp classes.You should create a WAR file or a separate context directory for your application under /webapps. If you're doing anything else, it's wrong.
Create JNDI in sever.xml as mentioned.Nope. Shouldn't be editing server.xml. Put that stuff in an application-specific context.xml, which goes in the META-INF of your WAR file.
Create reference in web.xml as mentioned.Good.
Goto conf/catalina/localhost/<webappname>.xmlNo need for this. Don't know what you're doing here.
add the line
<ResourceLink name="jdbc/Oracle"
type="javax.sql.DataSource" global="jdbc/Oracle"/>
replace Oracle with your datasource name.
and i got me workingMight be working, but it's not really correct.
% -
Getting JNDI not found on MySql/Tomcat
Has anyone gotten ADF to work with MySql/Tomcat? I think I finially have the app working in Tomcat but now I'm getting an error with my pool/JNDI lookup. At the tomcat console I get this;
SEVERE: Null component Catalina:type=DataSource,path=/ediweb,host=localhost,class=javax.sql.DataSource,name="jdbc/ediconnDS"
It looks like it can't even create a connection to MySql. My app has a context.xml in the META-INF like this;
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ResourceLink global="jdbc/ediconnDS" name="jdbc/ediconnDS" type="javax.sql.DataSource" />
</Context>
And in my server.xml I have this;
<Resource name="jdbc/ediconnDB" 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/freightedi"/>
In my web.xml I have this resource-ref;
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/ediconnDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I've tried putting the resource in the context.xml... all kinds of stuff, to no avail.
I tested these connection parameters in Squirrel SQL (java jdbc based SQL tool) and it works?!
Please help :(
Edited by: user10419690 on Apr 15, 2009 8:51 AMTomcat isn't giving any errors on boot and I have the MySql JDBC resource in it;
in the server.xml;
<Resource name="jdbc/ediconnDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="Slgedi01" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/freightedi?autoReconnect=true;ultraDevHack=true;capitalizeTypeNames=true;pedantic=true"/>
in my web.xml
<resource-ref>
<description>MySql Connection</description>
<res-ref-name>jdbc/ediconnDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
in my context.xml
<?xml version="1.0" encoding="utf-8" ?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ResourceLink global="jdbc/ediconnDS" name="jdbc/ediconnDS" type="javax.sql.DataSource" />
</Context>
The tomcat console says;
WARNING: ADFc: JNDI failure. Unable to lookup Data Source at context java:comp/env/jdbc/ediconnDS
oracle.jbo.DMLException: JBO-27200: JNDI failure. Unable to lookup Data Source at context java:comp/env/jdbc/ediconnDS
at oracle.jbo.server.DBTransactionImpl.lookupDataSource(DBTransactionImpl.java:1557)
at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:272)
The ADF Gui on the web page says;
Messages for this page are listed below.
JNDI failure. Unable to lookup Data Source at context java:comp/env/jdbc/ediconnDS
Name ediconnDS is not bound in this Context
Unexpected exception caught: java.lang.NullPointerException, msg=null
Anything? -
Problem loading jdbc driver in Tomcat
Hi,
I have got a connection to MySQL5.0 from TomCat 5.5.13, that was test correctly in development (JSC Upd 1) but I encounter the following deployment error :
com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
When I verify, I found that if I put the mysql Connector JDBC driver in <tomcat>/common/lib, there is no error.
But when the MySql Connector JDBC driver resides in <tomcat>/shared/lib, the error persists.
What's the difference ? shouldn't it work for both ?
Thanks in advance for any pointers and advise.hmm... i guess that it's a must to include the lib at /common/lib instead of shared/lib .
Is there a Tomcat resource that I can read up on ?
rgds -
Persistent Store Problems for MYSQL Enhanced Cluster With OpenMQ 4.4
I am trying to implement an enhanced cluster with failover. I have edited the config files for each broker instance for a persistent store. I have appended the following to each of the config.properties files:
imq.brokerid=myclusterinstanceINSTANCE1 # I substitute INSTANCE2 for INSTANCE1 for broker #2
imq.persist.store=jdbc
imq.persist.jdbc.dbVendor=mysql
imq.persist.jdbc.mysql.property.url=jdbc:mysql://xxx.xxx.xxx.xx:3306/test
imq.persist.jdbc.mysql.user=user1
imq.persist.jdbc.mysql.needpassword=true
imq.persist.jdbc.mysql.password=mypass
imq.cluster.ha=true
imq.cluster.clusterid=mycluster
imq.cluster.brokerlist=xxx.xxx.xxx.x:37676,yyy.yyy.yyy.y:37676
I then create the persistence storage with "imqdbmgr create tbl". When I view the data in the tables it creates, I have one row. Under Store_Version, I have 410. Under LOCK_ID, it has NULL. When I go to start the brokers with imqbrokerd, I get the following error:
ERROR [B3198]: Error initializing cluster manager:
com.sun.messaging.jmq.jmsserver.util.BrokerException: [B4239]: Failed to load persistent store version from database table MQVER41Cmycluster
at com.sun.messaging.jmq.jmsserver.persist.jdbc.VersionDAOImpl.getStoreVersion(VersionDAOImpl.java:310)
at com.sun.messaging.jmq.jmsserver.persist.jdbc.DBTool.updateStoreVersion410IfNecessary(DBTool.java:350)
at com.sun.messaging.jmq.jmsserver.persist.jdbc.JDBCStore.checkStore(JDBCStore.java:3599)
at com.sun.messaging.jmq.jmsserver.persist.jdbc.JDBCStore.<init>(JDBCStore.java:127)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.messaging.jmq.jmsserver.persist.StoreManager.getStore(StoreManager.java:157)
at com.sun.messaging.jmq.jmsserver.Globals.getStore(Globals.java:967)
at com.sun.messaging.jmq.jmsserver.cluster.ha.HAClusterManagerImpl.initialize(HAClusterManagerImpl.java:181)
at com.sun.messaging.jmq.jmsserver.Globals.initClusterManager(Globals.java:903)
at com.sun.messaging.jmq.jmsserver.Broker._start(Broker.java:777)
at com.sun.messaging.jmq.jmsserver.Broker.start(Broker.java:410)
at com.sun.messaging.jmq.jmsserver.Broker.main(Broker.java:1971)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1103)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2777)
at com.sun.messaging.jmq.jmsserver.persist.jdbc.VersionDAOImpl.getStoreVersion(VersionDAOImpl.java:298)
... 16 more
I believe this error is attributed to the NULL value under LOCK_ID. I think that the value under LOCK_ID should be the name of the broker from the config file (even though I specified them in the config files). Any ideas?? THANKS!Just some pointers -- maybe this will be of use:
If you haven't already read it, please take a look at the [ MySQL setup guide|https://mq.dev.java.net/OpenMQ_MySQLCluster_Setup_Guide.html] .
We recommend using NDB Data-store of MySQL Cluster, though this isn't an absolute requirement. Due to some issues we have found with earlier versions, we recommend using MySQL Cluster, 7.0.9 or better (the current version is 7.0.16, or 7.1.5). Either of these would contain Connector/J.
I'd also recommend using the latest version -- MQ 4.4update2 (just in case you happen to have an older copy). There were many minor improvements in the integration with MySQL from the original 4.4 release, to update 2. This is linked at the MQ download page: [https://mq.dev.java.net/downloads.html] -
Help needed for MySQL 5 database DSN less connection with Oracle reports
Hi,
I am using Oracle Develper Suite and java (J2EE) for my application. I am using MySql 5 as database tool. I want to use Oracle reports of Oracle Develper suite. I have created some reports by first creating system DSN for MySql database and then connect Oracle reports to that DSN by "jdbc:odbc" connection string provided in Oracle Report developer wizard. This is working fine.
I want to generate reports without creating system DSN (DSN less) so that i can use my application on any computer without creating DSN for Oracle Reports. I am deploying my application on OC4j as "EAR" file.
Help in this regard will be highly appreciated.
Regards.Using an 8i client, you will need to configure the tnsnames.ora file with appropriate connection information if you are using local naming. If you are using host naming or something like an Oracle Names server to resolve TNS aliases, you can skip the tnsnames.ora configuration. A default installation of the Oracle client, though, will probably be using local naming.
If the tnsnames.ora file is configured, or you have configured an alternate way of resolving TNS aliases, you should be able to use the connection string
DRIVER={Oracle ODBC Driver};DBQ=<<TNS alias>>;UID=system;PWD=managerIf you wanted to move to the 10g client (the 10g Instant Client could be useful here), there are some streamlined naming methods that could be used instead of configuring the tnsnames.ora file.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
I have a problem with JDBC Realm in Tomcat/Oracle/Win XP
I have a problem with JDBC Realm in Tomcat.
I have attached my server.xml file located in the
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
The Problem is that when I login I get the user name and password prompt but it does not resolve.
When I enter in the tomcat-users.xml password with memory realm uncommented it works fine.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\tomcat-users.xml
Is there a cache or something I need to reset for the JDBC Realm to work?
I have attached my tables and contents as well...
Did I miss something????
Thanks
Phil
server.xml
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
</GlobalNamingResources>
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Catalina">
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector
port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
<!--
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
connectionName="testName" connectionPassword="testPass"
userTable="users"
userNameCol="user_name"
userCredCol="user_pass"
userRoleTable="user_roles"
roleNameCol="role_name" />
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
Tables
create table users
user_name varchar(15) not null primary key,
user_pass varchar(15) not null
create table roles
role_name varchar(15) not null primary key
create table user_roles
user_name varchar(15) not null,
role_name varchar(15) not null,
primary key( user_name, role_name )
select * from users;
----------------------+
| user_name | user_pass |
----------------------+
| tomcat | tomcat |
| user1 | tomcat |
| user2 | tomcat |
| user3 | tomcat |
----------------------+
select * from roles;
| role_name |
| tomcat |
| role1 |
select * from user_roles;
-----------------------+
| role_name | user_name |
-----------------------+
| tomcat | user1 |
| role1 | user2 |
| tomcat | tomcat |
| role1 | tomcat |
-----------------------+Jan 2, 2008 11:49:35 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 2, 2008 11:49:35 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 734 ms
Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.9
Jan 2, 2008 11:49:35 AM org.apache.catalina.realm.JDBCRealm start
SEVERE: Exception opening database connection
java.sql.SQLException: oracle.jdbc.driver.OracleDriver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:684)
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:758)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1004)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Jan 2, 2008 11:49:36 AM org.apache.catalina.core.StandardContext resourcesStart -
How to set class path for mysql
hai, I have been trying to make a java program read from mysql database. but i don't know how to set the class path for mysql-connector-java-5_1_.0.6-bin. i set the class path in system variable as C:\Program Files\Java\jdk1.5.0_08\jre\lib\ext\mysql-connector-java-5_1_.0.6-bin.
in the command prompt, i compile C:\javac abc.java and run java abc.
when run it come out error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
i am using Window xp. can anybody help me??? TQ.hai, I have been trying to make a java program read
from mysql database. but i don't know how to set the
class path for mysql-connector-java-5_1_.0.6-bin. i
set the class path in system variable as C:\Program
Files\Java\jdk1.5.0_08\jre\lib\ext\mysql-connector-jav
a-5_1_.0.6-bin.
in the command prompt, i compile C:\javac abc.java
and run java abc.
when run it come out error
java.lang.ClassNotFoundException:
com.mysql.jdbc.Driver
i am using Window xp. can anybody help me??? TQ.Right click on my computer icon,
Goto properties->advanced->environment variables.
Look for 'classpath' under system variable.
Select it and click edit.
put ';' and path of the mysql connector jar at the end
suppose if u have jar file under d:/driver/mysqlconnector.jar
thn put this value in variable value text box
;d:/driver/mysqlconnector.jar
or simply put ur driver jar file in jre/lib/ext folder
D:\j2sdk1.4.2_03\jre\lib\ext
[Servlet tutorial|http://www.jsptube.com] -
Problems using Quick Migrate in SQL Developer 1.5 for MySQL to Oracle 10g
Hi all,
I am trying to use SQL Developer 1.5 migration tools (Quick Migrate) to perform online capture and build source model to migrate from MySQL 5.x to Oracle 10g on Windows platform. I get these errors and the Quick Migrate process fails:
oracle.dbtools.metadata.persistence.PersistableObject.doInsert(PersistableObject.java:238)
I did a search and used the sqldeveloper.cmd script but still fails. Then I created a new database and truncated the repository. I now get the above error plus two new ones listed below:
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
Error loading nls:OALL8 is in an inconsistent state
Error occurred during capture: Protocol violation
It fails during the capture process for MySQL 5.1 database
when it begins to capture the tables from MySQL.
Does anyone know how to resolve these issues when migrating from MySQL to Oracle 10g using Quick Migrate with SQL Developer 1.5 release?
Regards,
Ben Prusinski
Message was edited by:
benprusinski
Message was edited by:
benprusinskiHi all,
I put the following in my sqldeveloper.cmd file:
SET ORACLE_HOME=%CD%
What is very confusing is that with SQL Developer 1.5, there are several levels and several SQL Developer executables! I am really not sure which of these to use:
I created the SQLDeveloper 1.5 directory called SQLDeveloper1_5 on Windows:
1) cd C:\sqldeveloper1_5\sqldeveloper-5338
there exists a sqldeveloper.exe
2) cd c:\sqldeveloper1_5\sqldeveloper-5338\sqldeveloper\sqldeveloper.exe
3) cd c:\sqldeveloper1_5\sqldeveloper-5338\sqldeveloper\sqldeveloer\bin\sqldeveloper.exe
Which SQLDeveloper 1.5 executable should I be using and where should I place the
sqldeveloper.cmd file?
Also I did try to use a different database and schema for the repository with Quick Migrate but it appears a bug exists in SQL Developer 1.5 version that causes errors with Quick Migrate for MySQL to Oracle? Is this correct?
As an update, I ran the following commands:
cd to
c:\sqldeveloper1_5\sqldeveloper-5338\sqldeveloper\sqldeveloper\bin
sqldeveloper.cmd sqldeveloper.exe
Start sqldeveloper.exe
Perform standard capture for MySQL using the new mig2 schema as the new repository
It starts the capture but fails on the errors below:
Error loading nls:OALL8 is in an inconsistent state
UPDATE
============================
I tried this again and it worked with the exception of one error message listed below:
Here are the steps that I followed:
1. Create a Windows cmd script
Put the following entries in the script:
SET ORACLE_HOME=%CD%
save the command windows script as sqldeveloper.cmd
Copy this script to the base installation directory for SQLDeveloper
Example:
1. cd c:\SQLDeveloper1_5\sqldeveloper-5338\sqldeveloper
2. Start SQLDeveloper with the command script that you created earlier
Example:
Open a Windows shell prompt window and execute the following scripts:
a) sqldeveloper.cmd sqldeveloper.exe
b) sqldeveloper.exe
3) In SQL Developer 1.5
From the Migrate menu,
a) Delete current repository and create a new schema in Oracle target database call it mig2.
b) Then create a new repository in SQL Developer 1.5
c) Right mouse click on the MySQL 5.x database and choose capture
It worked with the exception of one error message:
o.jdbc.driver.OracleDriver
Error while registering Oracle JDBC Diagnosability MBean.
So it looks like something is screwed up with my JDBC drivers and configuration for MySQL. How do I diagnose the JDBC driver issue for MySQL?
Thanks!!!
Ben
Thanks
Ben
Maybe you are looking for
-
Applescript to convert PDF to JPEG using Preview?
I know there's an existing script available on the internet that converts PDFs to JPEGs (it's here: http://macscripter.net/viewtopic.php?id=25350) BUT, for whatever reason, the quality, even when set to 600dpi, is crap. I get better results simply op
-
Dba_index_name and dba_ind_columns showing different results
Hi All, I am confused why it is showing different results: [email protected]#>select index_name from dba_indexes where table_name='CRBTPROV_FINAL'; INDEX_NAME CRBTPROV_INDX1 [email protected]#>select index_name from dba_IND_COLUMNS where table_name='
-
Hi there, I created new apple id but can't sign in to itunes. It says that your id is not yet loged in so you have to review. In revies it shows payment method in which I provide full info of my visa card but it shows that the pin is incorrect a
-
Not able to connect to Data service on Airtel
Hi! I have a nokia Lumia 800 handset with airtel as service provider, I activated their GPRS data service (read edge) and I am not able to connect to internet, however earlier I had Vodafone and I never faced such issues with it, I have tried out eve
-
Hi, I have recently decided to try out dreamweaver CS5 and almost immediately upon installation all the syntax coloring in gone. In the menu the option is not grayed out but no matter how manner times I click on it it's not turning on. I have checked