Jdbc through mysql
how i can connect jdbc to a java program through mysql in netbean 6.9.1 with user name and password.
Quite old hint but maybe will be helpful. Look here.
Similar Messages
-
Need help setting up JDBC with mySQL and Netbeans
I've successfully got mySQL up and running and created a few simple test databases. I've been following the instructions on this website (http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1 ) to get JDBC working but have had little luck.
I've downloaded JDBC from mySQL website, extracted the mysql-connector-java-3.1.13-bin.jar file and changed the class path to :
C:\Program Files\Java\jre1.5.0_06\lib\ext\mysql-connector-java-3.1.13-bin
which is where I placed the .jar file.
I then used the following code provided on stardeveloper.com to test a connection with the test database.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JdbcExample2 {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test",
"root", "secret");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}It compiles but when run I get the error message :
java.lang.NoClassDefFoundError: testdatabase/JdbcExample2
Exception in thread "main"I assume this means that my classpath isn't setup correctly but I have no idea what's up and how to correct it.
Can someone PLEASE tell me how to setup jdbc and what I've done wrong.
Thanks in advance :)Thanks for your reply. I've made some progress but I'm still having problems.
In mySQL I created a new user called uraknai with password n0121429 and granted them access to a test database I created called pet.
Then, in netbeans, I clicked the Runtime tab, clicked Databases and rightclicked Drivers and clicked Add Driver. I then added the driver mysql-connector-java-3.1.13-bin.jar. I then right clicked the newly added driver and selected the connect using option. I filled in the appropriate boxes clicked ok and it connected successfully.
Then, under the project tab, I right clicked the project name, clicked properties then clicked Libraries and added the .jar file mysql-connector-java-3.1.13-bin.jar
I then ran the following code to test the connection to the database:
import java.sql.*;
public class ConnectionTest {
public ConnectionTest() {
public static void main(String[] args)
System.out.println("BEGIN CONNECTION TEST");
Connection conn = null;
try
String userName = "uraknai";
String password = "n0121429";
String url = "jdbc:mysql://localhost/pet";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
catch (Exception e)
System.err.println ("Cannot connect to database server");
finally
if (conn != null)
try
conn.close ();
System.out.println ("Database connection terminated");
catch (Exception e) { /* ignore close errors */ }
}and get the message:
java.lang.NoClassDefFoundError: math/ConnectionTest
Exception in thread "main"
Java Result: 1when I run the code.
Can someone explin what I've done wrong and how to fix the problem.
Cheers. -
JDBC or MySQL cache - update query
The following query is ok but only works after a second refresh of the page.
The query is manupulated by the URL:
UPDATE activiteiten SET afgerond = 'checked' WHERE id=6
UPDATE activiteiten SET afgerond = 'unchecked' WHERE id=6
The query works (without errors) but somethime the query was not executed. My teacher said he thought that it was the cache. He refers to ODBC because he known the problem there.
Maybe somebody here can help me to stop JDBC or MySQL caching, were can I configure it? Waiting for response, Adrido a commit after your execution of statement..
-
JDBC through Applet...
We are getting 'AccessControlException' while using JDBC through Applet.
Can anybody suggest the changes to be made in the policy file OR security setting OR security Manager.The tutorial gives help about it at :
http://java.sun.com/docs/books/tutorial/security1.2/tour1/index.html
hope it will help. -
MySQL - Another 'Can't connect through mysql.sock' question...
Hey, folks.
So I'm trying to install MySQL to run with PHP on my PowerBook G4 (running 10.4.7, non-server edition) to use it to test out a shopping cart program for a website I'm building.
I had it working as of Monday, when I installed it, got all the permissions set, built the necessary tables, and changed the root password (and logged in just to make sure it worked before retiring for the night)...but today I realized that I had somehow installed the wrong version of MySQL (I connected to it earlier today and discovered it was 4.026 - and I needed to be running MySQL 4.1.20, in order to be running the same version as my webhost).
So I decided to upgrade. I downloaded and installed the 4.1.20 file, followed the directions about creating the system tables, changed permissions via sudo chown -R mysql:mysql data...and now, when I go to change the root user password (just to make sure it's still the same as it was), I get the following error:
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
This error also occurs when I try to simply startup MySQL. I also now find I can't connect via MySQL Admin, either - it gives me the same error. Pinging the host works, however.
Sooo...anyone have any ideas? I've read up on the forums re: Apple changing the socket to /var/mysql/mysql.sock as of 10.4.4, but it seems that would have affected me earlier this week when I was running the previous version of MySQL, too (I certainly haven't upgraded the OS since then).
Regardless, I can't connect through MySQL Admin using the /var/mysql/mysql.sock socket, anyway...nor the standard /tmp/mysql.sock.
Any thoughts on what might be causing this? I should confess, I'm well-versed in DOS (ugh), but UNIX is not really my strong suit, so I'm still figuring out how to get around in the Terminal...
Thanks so much for any input you can give me!
(Oh, one more thing, since it'll probably come up - I'm not currently connecting via PHP, but I will be eventually. Right now, I just want to be able to change my root password, and login from the Terminal)!
Thanks again!\
PowerBook G4 1GHz 15 Mac OS X (10.4.7)Alright, folks.
Somehow my computer has fixed itself. After wiping the mysql directories entirely, then reinstalling, I was still getting the same error.
After going back to the original "MySQL-On-Mac" site at Marc Liyanage's entropy.ch site & following some of the instructions there, somehow my problem seems to have fixed itself.
I wish I could tell you what the solution was (to benefit anyone else having this problem), but since I was simply following the unix commands listed there (without much explanation, at times, as to what they were doing), I just know that somehow it worked.
(But if I had to make a guess, I think it had to do with starting the server via sudo ./bin/mysqld_safe &)... -
Thin JDBC through firewall - what ports need to be open?
We are running Oracle 7.3, and Oracle Web Server on the same
computer. The firewall is set up to allow connections to that
computer from anywhere, on ports 80 and 1521.
Our thin JDBC applet works perfectly from inside the firewall,
but from outside, I get a time-out error trying to open the JDBC
connection.
What else needs to be done get JDBC through? Do other ports need
to be open on the firewall?
The JDBC FAQ mentions a "Net8 compliant" or "SQLNet certified"
firewall - is that relevant to this problem, and if so, what does
it really mean?
We are supposed to be operational right now, so many many thanks
for any help on this!
- Joe Wielgosz
nullTry in the Lion Server Forum?
Regards,
Colin R. -
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 -
JDBC/JSP/MySQL Code works from my local machine, but not on server
Hi there!
I've been struggling with this problem for a while.
I have a database from which I need to read and display some data on a browser. (The database is set up for remote access).
I'm using the following JSP/JDBC code to do that.
Class.forName ("com.mysql.jdbc.Driver").newInstance();
out.println("<BR> Connecting to DB...Pls. Wait <BR>");
Connection con = DriverManager.getConnection("url","user","pwd");
if(con.isClosed())
out.println("<BR><BR><BR>" +"Could NOT connect to MySQL Database...");
else out.println("<BR> CONNECTED !!! <BR>");
Statement stmt = con.createStatement();
results = stmt.executeQuery("SELECT * FROM TableName" );
When I run this of my local machine, it works fine. But when I upload it to a server, it doesn't run through. I dont get either the connected or not connected message.
I tried this piece of code that I found online to check the driver.
/*Driver d = (Driver)Class.forName("com.mysql.jdbc.Driver").newInstance();
out.println("<BR>Got a driver instance. ");
if (d.acceptsURL(url)) out.println("<BR>The driver does accept my URL");
else out.println("<BR>The driver doesn't like the URL I'm trying"); */
I ran it off the server and it worked. I got the outputs --Got a driver instance and The driver does accept my URL
I'm unable to figure out why this code can be run locally from my machine, but not from a different location. The database is NOT on my machine.
Any inouts will be really appreciated.
I'm using an Apache Tomcat container and the database is MySQL.Just wanted to mention
The database is on another (3rd) machine.
So I have
1. My local machine
2. Database hosted on a 2nd machine
3. Place I'm moving my code to (its basically a hosting account provided by an external company)
I can access the database from my local machine. However, when I move the code over to another machine, it doesn't work. -
A question about JDBC and MySQL
hello dear friends,ask a question:
if in MySQL database, i have defined a clumon as TEXT data type.
when i use JDBC, i use which kind of java data type to hold TEXT,
i mean which getXXX() method i should use.
is it possible i just use getObject() and cast it to a binarystream??
thanks in advanced.use this:
declare it 1st
String x ="";
then u can now get the value of the field...
x = getString("<fieldName>");is there length limitation?
for example, i want store a String which is got from a JTextArea, i also treat it as String and insert into the column with TEXT datatype like
insert table_name (text_column) values( string_1)
this works in JSP, should work in JAVA too...
hope i helped... ^_^ -
Problem in jdbc-tomcat-mysql connection
hi everybody
i m in serious problem since last 15-20 days. i m trying hard to make the connection jdbc-mysql using tomcat with the help of a jsp test page but every time i am facing almost the similar probems listed below in detail:
to make sure that the jdrivers's .jar (mysql-connector-java-3.1.7-bin.jar) available for such connections working fine i have tried the above said connection without using tomcat....which is working fine...for this i have created a dummy database with a dummy table ..and written some queries in the .java file of my code which upon running inserts the specified values in the defined(dummy) database.
this is the confirmation that the classpath etc..are ok in regard to the mysql-connector-java-3.1.7-bin.jar
now i have placed a copy of this .jar file in to the commons/lib directory of the tomcat web server(which is suppossed to be the place for such external jars)
after doing so i have followed 2 methods :
method 1st:........
i have made aone more jar file from the following .java file....
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class TestSQLLoad
String user = "Not Connected";
String pwd = "no pwd";
int id = -1;
public void init() {
try{
Context ctx = new InitialContext();
if(ctx == null ) {
throw new Exception("Boom - No Context");
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
if (ds != null) {
Connection conn = ds.getConnection();
if(conn != null) {
user = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
String q = "select name, password, id from user";
ResultSet rst = stmt.executeQuery(q);
if(rst.next()) {
user=rst.getString(1);
pwd=rst.getString(2);
id = rst.getInt(3);
conn.close();
}catch(Exception e) {
e.printStackTrace();
public String getUser() {
return user;
public String getPassword() {
return pwd;
public int getID()
return id;
after compiling it at the cmd prompt i made a .jar file from the .class of it and named it MySQLLoad.jar...then i placed it also in to the commons/lib directory where the mysql-connector-java-3.1.7-bin.jar was already placed.
then i have changed the server.xml and web.xml files from the conf directory of the tomcat as given here:
server.xml
<!-- 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">
<!-- Comment these entries out to disable JMX MBeans support used for the
administration web application -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<!-- 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"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</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="Catalina">
<!-- 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 5 documentation bundle for more detailed
instructions):
* If your JDK version 1.3 or prior, 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 HTTP/1.1 Connector on port 8080 -->
<Connector
port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to 0 -->
<!-- Note : To use gzip compression you could set the following properties :
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
<!--
<Connector port="8443"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
<!-- See proxy documentation for more information about using this. -->
<!--
<Connector port="8082"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" acceptCount="100" connectionTimeout="20000"
proxyPort="80" disableUploadTimeout="true" />
-->
<!-- 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). -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">
-->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
<!-- 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.4
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"/>
-->
<!-- 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"
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"
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"
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"
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
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- Defines a cluster for this node,
By defining this element, means that every manager will be changed.
So when running a cluster, only make sure that you have webapps in there
that need to be clustered and remove the other ones.
A cluster has the following parameters:
className = the fully qualified name of the cluster class
name = a descriptive name for your cluster, can be anything
mcastAddr = the multicast address, has to be the same for all the nodes
mcastPort = the multicast port, has to be the same for all the nodes
mcastBindAddr = bind the multicast socket to a specific address
mcastTTL = the multicast TTL if you want to limit your broadcast
mcastSoTimeout = the multicast readtimeout
mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
in case of multiple ethernet cards.
auto means that address becomes
InetAddress.getLocalHost().getHostAddress()
tcpListenPort = the tcp listen port
tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
has a wakup bug in java.nio. Set to 0 for no timeout
printToScreen = true means that managers will also print to std.out
expireSessionsOnShutdown = true means that
useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
false means to replicate the session after each request.
false means that replication would work for the following piece of code: (only for SimpleTcpReplicationManager)
<%
HashMap map = (HashMap)session.getAttribute("map");
map.put("key","value");
%>
replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
* Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
* Synchronous means that the thread that executes the request, is also the
thread the replicates the data to the other nodes, and will not return until all
nodes have received the information.
* Asynchronous means that there is a specific 'sender' thread for each cluster node,
so the request thread will queue the replication request into a "smart" queue,
and then return to the client.
The "smart" queue is a queue where when a session is added to the queue, and the same session
already exists in the queue from a previous request, that session will be replaced
in the queue instead of replicating two requests. This almost never happens, unless there is a
large network delay.
-->
<!--
When configuring for clustering, you also add in a valve to catch all the requests
coming in, at the end of the request, the session may or may not be replicated.
A session is replicated if and only if all the conditions are met:
1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
2. a session exists (has been created)
3. the request is not trapped by the "filter" attribute
The filter attribute is to filter out requests that could not modify the session,
hence we don't replicate the session after the end of this request.
The filter is negative, ie, anything you put in the filter, you mean to filter out,
ie, no replication will be done on requests that match one of the filters.
The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
ending with .gif and .js are intercepted.
The deployer element can be used to deploy apps cluster wide.
Currently the deployment only deploys/undeploys to working members in the cluster
so no WARs are copied upons startup of a broken node.
The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
When a new war file is added the war gets deployed to the local instance,
and then deployed to the other instances in the cluster.
When a war file is deleted from the watchDir the war is undeployed locally
and cluster wide
-->
<!--
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="4001"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"
ackTimeout="15000"/>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
<Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
</Cluster>
-->
<!-- 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" />
-->
<!-- 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"/>
-->
<!-- 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.
This access log implementation is optimized for maximum performance,
but is hardcoded to support only the "common" and "combined" patterns.
-->
<!--
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<Context path="/testdb" docBase="TOMCAT_HOME/webapps/tomcat-docs/testdb"
debug="5" reloadable="true" crossContext="true" >
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<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>10</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>5</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>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>mysql</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.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/testdb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
</Host>
</Engine>
</Service>
</Server>
and the other xml file i.e
web.xml is here:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- ======================== Introduction ============================== -->
<!-- This document defines default values for all web applications -->
<!-- loaded into this instance of Tomcat. As each application is -->
<!-- deployed, this file is processed, followed by the -->
<!-- "/WEB-INF/web.xml" deployment descriptor from your own -->
<!-- applications. -->
<!-- -->
<!-- WARNING: Do not configure application-specific resources here! -->
<!-- They should go in the "/WEB-INF/web.xml" file in your application. -->
<!-- ================== Built In Servlet Definitions ==================== -->
<!-- The default servlet for all web applications, that serves static -->
<!-- resources. It processes all requests that are not mapped to other -->
<!-- servlets with servlet mappings (defined either here or in your own -->
<!-- web.xml file. This servlet supports the following initialization -->
<!-- parameters (default values are in square brackets): -->
<!-- -->
<!-- debug Debugging detail level for messages logged -->
<!-- by this servlet. [0] -->
<!-- -->
<!-- input Input buffer size (in bytes) when reading -->
<!-- resources to be served. [2048] -->
<!-- -->
<!-- listings Should directory listings be produced if there -->
<!-- is no welcome file in this directory? [true] -->
<!-- -->
<!-- output Output buffer size (in bytes) when writing -->
<!-- resources to be served. [2048] -->
<!-- -->
<!-- readonly Is this context "read only", so HTTP -->
<!-- commands like PUT and DELETE are -->
<!-- rejected? [true] -->
<!-- -->
<!-- readmeFile File name to display with the directory -->
<!-- contents. [null] -->
<!-- -->
<!-- For directory listing customization. Checks localXsltFile, then -->
<!-- globalXsltFile, then defaults to original behavior. -->
<!-- -->
<!-- localXsltFile Make directory listings an XML doc and -->
<!-- pass the result to this style sheet residing -->
<!-- in that directory. This overrides -->
<!-- globalXsltFile[null] -->
<!-- -->
<!-- globalXsltFile Site wide configuration version of -->
<!-- localXsltFile This argument is expected -->
<!-- to be a physical file. [null] -->
<!-- -->
<!-- -->
<servlet>
<servlet-name>default</servlet-name>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- The "invoker" servlet, which executes anonymous servlet classes -->
<!-- that have not been defined in a web.xml file. Traditionally, this -->
<!-- servlet is mapped to the URL pattern "/servlet/*", but you can map -->
<!-- it to other patterns as well. The extra path info portion of such a -->
<!-- request must be the fully qualified class name of a Java class that -->
<!-- implements Servlet (or extends HttpServlet), or the servlet name -->
<!-- of an existing servlet definition. This servlet supports the -->
<!-- following initialization parameters (default values are in square -->
<!-- brackets): -->
<!-- -->
<!-- debug Debugging detail level for messages logged -->
<!-- by this servlet. [0] -->
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- The JSP page compiler and execution servlet, which is the mechanism -->
<!-- used by Tomcat to support JSP pages. Traditionally, this servlet -->
<!-- is mapped to the URL pattern "*.jsp". This servlet supports the -->
<!-- following initialization parameters (default values are in square -->
<!-- brackets): -->
<!-- -->
<!-- checkInterval If development is false and checkInterval is -->
<!-- greater than zero, background compilations are -->
<!-- enabled. checkInterval is the time in seconds -->
<!-- between checks to see if a JSP page needs to -->
<!--Look at the URl below:
How to connect to Microsoft SQL server with Type 4 JDBC driver
http://www.java-tips.org/content/view/615/29/ -
JDBC and MySQL connectivity problem
The code i hav attached generates Connectivity exception.. the prob is with the part in bold.. can anyone help
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class testconn {
public static void main(String args[]) {
Connection con = null;
String serverName = "localhost:8080";
String mydatabase = "imagedb";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "am";
String password = "ta";
try {
Class.forName("com.mysql.jdbc.Driver");
con= DriverManager.getConnection(url, username, password);
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e);
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}I had such issue too, and I fixed it by adding in the environment variables the CLASSPATH entry that pointed to all the directories containing the .jar needed for the applications.
for example I used jodbc folder to connect mysql database (I installed last version and I got same issue than yours and it seems to be a 'connector' issue, exactly the same issue than yours) I got something like
CLASSPATH=my root dir/the java dir/the lib dir/jodbc;my root dir/the java dir/other important libs containing .jar files;
This is what I got for the issue, still working around (at the level of mysql all is ok, ...)
Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Hurukan>java ConnectJODBC brol
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
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 ConnectJODBC.main(ConnectJODBC.java:108)
[exception] -- la valeur de 'con' est nulle (DriverManager � retourn� une valeur
nulle)
C:\Documents and Settings\Hurukan>set
APPDATA=C:\Documents and Settings\Hurukan\Application Data
CLASSPATH=c:\Program Files\Java\jdk1.5.0_06\lib;c:\Program Files\Java\jdk1.5.0_06\dev;\c:\Program Files\Java\jdk1.5.0_06\lib\jodbc;
Here is the code that generated this exception
String dburl="jdbc:mysql://127.0.0.1/nosdisques"; // should be next passed by command line
String password="**scrambled**";
String username="**scrambled**";
Connection con=null;
Statement stmt=null;
ResultSet res=null;
String requete="";
String strToWrite="";
// Connexion � la base de donn�e
// Won't work with mysql 5.0.18, mysql connector 3.51.12 is installed [???]
// Previous tests with 5.0.18 were running good, that has started with the last os restoration (and the connector was different of course...)
// tried to retreive older version of the mysql connector
try
Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection(dburl,username,password);
System.out.println("Nous sommes connect\u201as \u2026 la base " + con.getCatalog());
catch(SQLException sqlex)
System.out.println("[sqlexception]\n");
System.exit(3);
catch(Exception ex)
ex.printStackTrace();
if(con == null)
System.out.println("[exception] -- la valeur de 'con' est nulle (DriverManager \u2026 retourn\u201a une valeur nulle)\n");
System.exit(4);
System.out.println("Impossible to join database, access denied\n");
System.out.println("Verify settings (mysqld or firewall)\n"); System.exit(2);
Maybe the drivers used (last one: connector/j 3.1.12). The .jar file is in the %classpath% directory c:\Program Files\Java\jdk1.5.0_06\lib.
Can't really understand why this code won't run anymore, ...
I took a look on the other computer where the same code is running ok.
These are the differences:
mysql server is 5.0.18 on the other computer the version is 3.23.41
mysql connector is 3.51.12 on the other computer the version is 3.0.10
access rights are the same because the database is the dumped one from 3.23.41 to 5.0.18, and I'm quite good with the dbms management (I'm IT developper in fact, trying to take over java technology ;) )
in this case this is not a sql error but java error.
the jar file is set to the %classpath% folder on both computers
I copied the jar from the other computer, removing the new .jar file and... it failed, exactly the same issue
Still working around, ...
Dimitri -
JDBC Java- mysql problem help!
Hi, I wnat to connect to mySQL fromo Java, I followed all the instructions from the mySql web page, yet I havent been able to do it, when I compile the java progrm I keep getting class not found exceptions, I am using Fedora Core and Java was already installed-well I chose to install it when I installed the operating system, the point is that the paths are all assigned by he system not by me.
WHat can I do?, Ive been trying over andover again with no results, hopefully somebody can help, I tried to include all the configuration in this email,
thank you
my java program is the following:
t.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class t {
public static void main (String[] args) {
System.out.println("Hello, world!\n");
Class.forName("com.mysql.jdbc.Driver");
when I javac t.java
I have the following error
4. ERROR in t.java
(at line 11)
Class.forName("com.mysql.jdbc.Driver");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unhandled exception type ClassNotFoundException
when I comment out the Class.forName the hello world rogram runs fine
when I vi /etc/java java.conf this is the result
# System-wide Java configuration file -- sh --
# JPackage Project [www.jpackage.org]
# Location of jar files on the system
JAVA_LIBDIR=/usr/share/java
# Location of arch-specific jar files on the system
JNI_LIBDIR=/usr/lib/java
# Root of all JVM installations
JVM_ROOT=/usr/lib/jvm
# You can define a system-wide JVM root here if you're not using the default one#JAVA_HOME=$JVM_ROOT/java-gcj
# Options to pass to the java interpreter
JAVACMD_OPTS=
~
[root@localhost test]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
echo $JAVA_HOME
it contains nothing
ls /usr/share java*
java
java-1.3.0
java-1.4.0
java-1.4.1
java-1.4.2
java-1.5.0
javadoc
java-ext
java-utils
mysql-connector-java-3.1.13-bin.jar is under
/usr/share/java
in /etc/profile I have:
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java-3.1.13-bin.jar
in /root/.bash_profile i have
CLASSPATH=/usr/share/java/mysql-connector-java-3.1.13-bin.jar:/usr/lib/java-ext/mysql-connector/mysql-connector-java-3.1.13-bin.jar
export CLASSPATH
when I echo $PATH i have
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/binThanks duff,
The driver seems to be found
when I run
public class t {
public static void main (String[] args) {
try
System.out.println("Hello, world!\n");
Class.forName("com.mysql.jdbc.Driver");
System.out.println("MySQL Driver Found");
catch (ClassNotFoundException e)
System.out.println("MySQL Driver NOT Found");
e.printStackTrace();
I feel somehow ive been focusing in the wrong side of the problem due to my ignorance in Java. Please help me to understand, the reson for which ithe runtime was telling me that there was an unhandled exception was because it is a requirement to handle all exceptions of this kind? why wouldnt it cmplain if I jst did the hello world without any exception handling, maybe because it is a requirement in the Class.forName...
the other question is, is the message I was obtaining completely independent of the fact that the class was or was not found?
Maybe, I should go with these questions to the newbies forum...
thanks -
I am writing a Java Servlet that needs to connect to a MySQL database.
I would like to know which Java drive a need to use and also the java code that creates the connection on a Windows platform.
Thank you for your help.
LuisThis is a sample code. Try to have a look. And u also have to download MM-Mysql driver. Hope this helps u!
<%@ page import="java.util.*" %>
<%@ page import="star.utiltools.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Border" content="none">
<title>Log Monitor By MYSQL</title>
</head>
<body bgcolor="#E2E2E2">
<jsp:useBean id="MySQLListLoader" scope="session" class="star.utiltools.MySQLListLoader"/>
<jsp:setProperty name="MySQLListLoader" property="*"/>
<form name="infoForm" method=GET action="testTableListMySQL.jsp">
<font class="BODYHEADER">Log Monitor</font><BR>
<hr color="#008000" noshade size="1">
<%
//Set variable by request parameter
String DBColName = request.getParameter("colName");
String filterValue = request.getParameter("filterValue");
String filterCol = request.getParameter("filterCol");
Connection conn = null;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
catch (Exception e) {
out.println("Unable to load driver." + e);
try {
conn = DriverManager.getConnection("jdbc:mysql://172.16.88.86/test");
catch (NullPointerException e) {
e.printStackTrace();
catch (SQLException e) {
SQLException sqle = new SQLException("Unable to make conn " + e.toString() );
out.println("Unable to make conn :" + e.toString() );
throw sqle;
catch (Exception e) {
Exception ee = new Exception("Connecting error :" + e.toString() );
out.println("Connecting error :" + e.toString() );
throw ee;
if(conn == null) throw new NullPointerException(" Connection fails ");
* Set Display Column Name
Vector displayColName = new Vector();
displayColName.addElement("System");
displayColName.addElement("Report Mode");
displayColName.addElement("Profile ID");
displayColName.addElement("Submit User");
displayColName.addElement("Status");
displayColName.addElement("Filename");
displayColName.addElement("Start Time");
displayColName.addElement("End Time");
displayColName.addElement("Comment");
displayColName.addElement("Reserved 1");
displayColName.addElement("Reserved 2");
* Core Part
try
MySQLListLoader.reset();
MySQLListLoader.setConnection(conn);
MySQLListLoader.setDefaultPage("testTableListMySQL.jsp");
MySQLListLoader.setDisplayColName(displayColName);
MySQLListLoader.setHeaderColor("bgcolor='#7DBEAA'");
MySQLListLoader.setBgcolor("bgcolor='#7DBEFF'" , "bgcolor='#C4E1FF'" ); // Set bgcolor
//Set SQL
MySQLListLoader.setSelectStat("SELECT * FROM SCHEDULELOG");
if(filterValue == null || filterCol == null || filterValue.equals("*") || filterValue.equals(""))
{MySQLListLoader.setWhereStat("WHERE 0 = 0 ");}
else
{ MySQLListLoader.setWhereStat("WHERE " + filterCol + "= '" + filterValue + "'");}
if(DBColName == null)
{ MySQLListLoader.setDefaultOrderBy("SYSTEM"); }
else
{ MySQLListLoader.setDefaultOrderBy(DBColName);}
//Set for add new
MySQLListLoader.setAddNewLink("addnew.jsp?typr=add");
out.println(MySQLListLoader.generatedPage());
}catch(SQLException ex){
out.println("<BR>SQL Error in generated list : " + ex.toString());
}catch(Exception ex){
out.println("Error in generated list : " + ex.toString());
%>
</form>
</body>
</html> -
Very urgent !!!!!!!! Jdbc error mysql error
hii
i am not been able to connected to d/b ,i am using mySQL..
so plz tell me the soln.i have downloaded the connector j and set the class path..now tell me how to connect the d/b..also tell me how to that we r connectd to the database ,if possible send me the whole code..it will veru good help...
thanks...
take care.
RahulHii essube
i am u code for all my classes
1.Database class(just does the Connection to D/B)
2.LanguageFunctions class(class which does the Proccessing)
3.LanguageDetailsServlet class(Servlet)
1.Databaseclass
package Langpack;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.net.URL;
public class Databaseclass
Databaseclass objDatabaseclass=new Databaseclass();
Connection con=null;
public Databaseclass()
System.out.println("Me inside the Database Class");
protected Connection openConnection()
// Init the properties
Properties moConnectionProperties = new Properties();
moConnectionProperties.put("host", "localhost");
moConnectionProperties.put("port", "3306");
moConnectionProperties.put("database", "BAEKO");
moConnectionProperties.put("driver", "com.mysql.jdbc.Driver");
moConnectionProperties.put("user", "root");
moConnectionProperties.put("password", "password");
// load the driver
try {
Class.forName("com.mysql.jdbc.Driver");
//Class.forName("org.gjt.mm.mysql.Driver");
catch (Exception ex)
System.err.println("driver Class not found\n" + ex);
System.exit(-1);
// connect to database
try {
String mSURL = "jdbc:mysql://" + moConnectionProperties.get("host") + ":" +
moConnectionProperties.get("3306") + "/" + moConnectionProperties.get("BAEKO");
con = DriverManager.getConnection(mSURL, moConnectionProperties);
catch (Exception ex)
System.err.println("can't connect database\n" + ex);
System.exit(-1);
return con;
public void closeConnection()
try{
con.close();
catch(Exception e){;}
2.LanguageFunctions Class
package Langpack;
import java.io.*;
import java.sql.*;
import java.util.*;
public class LanguageFunctions extends Databaseclass
public LanguageFunctions()
super();
LanguageDetails getDetails(String X)
LanguageDetails objLanguageDetails=null;
try
Statement st=con.createStatement();
ResultSet result=st.executeQuery("Select languageName From LanguageMast Where languageNo='"+ X +"';");
objLanguageDetails=new LanguageDetails();
objLanguageDetails.languageName=result.getString ("languageName");
objLanguageDetails.languageNo=result.getString("languageNo");
catch(Exception e)
return objLanguageDetails;
LanguageDetails getAllDetails()
int i=0;
LanguageDetails vArray[]=null;
LanguageDetails objLanguageDetails=null;
try
Statement st=con.createStatement();
ResultSet result=st.executeQuery("Select * From LanguageMast;");
while(result.next())
objLanguageDetails=new LanguageDetails();
objLanguageDetails.languageName=result.getString("languageName");
objLanguageDetails.languageNo=result.getString("languageNo");
vArray=objLanguageDetails;
i++;
objLanguageDetails=null;
catch(Exception e){;}
return objLanguageDetails;
boolean saveDetails(Vector X)
LanguageDetails objLanguageDetails=null;
Vector objVector=null;
objVector=X;
String vlanguageName;
String vlanguageNo;
try
Statement st=con.createStatement();
objLanguageDetails=new LanguageDetails();
objLanguageDetails=(LanguageDetails)objVector.elementAt(0);
vlanguageName=objLanguageDetails.languageName;
vlanguageNo=objLanguageDetails.languageNo;
ResultSet rls=st.executeQuery("SELECT * FROM LanguageMast WHERE languageNo='"+ vlanguageNo +"'");
if (rls.getRow()==0)
rls.moveToInsertRow();
rls.updateString(vlanguageName,"languageName");
rls.updateString(vlanguageNo,"languageNo");
rls.insertRow();
else
rls.updateString(vlanguageName,"languageName");
rls.updateRow();
return false;
catch(Exception e)
return true;
3.LanguageDetailsServlet class
package Langpack;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
public class LanguageDetailsServlet extends HttpServlet
public String vlanguageNo;
public String vlanguageName;
PrintWriter pw;
public void service(HttpServletRequest req, HttpServletResponse res)
LanguageFunctions objLanguageFunctions=null;
LanguageDetails objLanguageDetails=null;
Vector vect=new Vector();
try
vlanguageNo=req.getParameter("txtLanguageNo");
vlanguageName=req.getParameter("txtLanguageName");
objLanguageDetails=new LanguageDetails();
pw=res.getWriter();
res.setContentType("text/html");
pw.println("<html><body>"+vlanguageNo+"</body></html>");
pw.println("<html><body>"+vlanguageName+"</body></html>");
objLanguageDetails.setNo(vlanguageNo);
objLanguageDetails.setName(vlanguageName);
vect.addElement(objLanguageDetails);
objLanguageFunctions=new LanguageFunctions();
objLanguageFunctions.saveDetails(vect);
catch(Exception e)
pw.close();
guys this is code and i am getting error after cliking th submit button on my wepage as:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
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.StandardContext.invoke(StandardContext.java:2415)
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:171)
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:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)
root cause
java.lang.StackOverflowError
Apache Tomcat/4.1.24
now tell me the soln of this..i am really fed up of this..plz help me
also tell me hw to check the connection is done or not...thanks
waiting for ur suggetions
Take Care
Rahul. -
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.
%
Maybe you are looking for
-
Why can't I create a response to an email from the Viewer window?
Why can't I create a response to an email from the Viewer window? When I select an email to respond to in the viewer window and click on the respond arrow that appears just under the header, a new response email opens for a split second then disappea
-
How to create a DVD that can play on a computer
I've finally become familiar with using Premiere Pro CS3 and Encore. When I'm creating a DVD I understand that it will be played on any standard DVD player but I would also like to have it play on a computer. Is there a setting which will allow this
-
How can I keep responses for each question of quiz.
For auditing purposes, I need to be able to record the user's answers for each of the 35 quiz questions. How can I accomplish this? Perhaps I can have the answers generated to a final answer page.
-
how do I get the audio to come put of the mac book pro and not the dv device when Im editing? Id like to be able to here it on the mac book pro speakers or on head phones conected to it! sorry for such a stup[id question
-
HT1414 wifi option is greyed out, unable to conncet to wifi
iPhone 4S Wifi is off, and grayedout. 4S is not able to connect to wifi