Problem using JDBC to connect to WBEM ODBC driver
Hello,
I've got a problem to connect to WBEM ODBC driver using JDBC. The error is:
exception due a la requetejava.sql.SQLException: [Microsoft][WBEM ODBC Driver]Unable to connect
When I try to connect to a MS access database, replacing only the ODBC source name, it's working. I can access to the MS access db. But when I put the WMI ODBC source name, WMI, I've got this error.
Does anybody know what could happened? Is it possible to access to WMI through JDBC? With MS access, accessing WMI ODBC is working !
Thanks very much for your help.
Here is the part of the source code :
import java.sql.*;
import java.io.*;
public class Main_1 {
/** Creates a new instance of Main_1 */
public Main_1() {
* @param args the command line arguments
public static void main(String[] args) {
try {
String url = "jdbc:odbc:WMI";
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url);
String query = "Select * from Win32_Processor";
//String query = "Select * from test;";
ResultSet results;
Statement stmt = con.createStatement();
results = stmt.executeQuery(query);
//System.out.println (results);
catch(Exception e){
System.out.println("exception due a la requete" + e);
e.printStackTrace();
}
you have to first start the network listener before you can run the program
start TNSLSNR before running the jdbc program
Similar Messages
-
I want to use jdbc to connect MS SQL SERVER
hi,
I want to use jdbc to connect MS SQL SERVER,not the jdbc-odbc bridge.
I download the driver from MS,deploy it,but when I connect the database such as:
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");%>
<%String sConnStr="jdbc:microsoft:sqlserver://computer2000:1433";%>
<%Connection conn=DriverManager.getConnection(sConnStr,"sa","123");%>
<%Statement stmt=conn.createStatement();%>
but it said
javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
how can i work out this problem
maybe my configure is wrong,please give me a successful sample configuration
thanks a lotHi,
I am not sure where you have got the following code from
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
What happens here, is Java Runtime will search for the Class named:
com.microsoft.jdbc.sqlserver.SQLServerDriver
If this Class is not in the Runtime Classpath, it will throw the Error that you have got. Kindly get the proper driver as well as ensure that the Class is available in the Runtime Classpath.
Thanks and regards,
Pazhanikanthan. P -
How to use JDBC database connection in Solaris
Hi all,
I am new to Solaris and i want to create an application using JDBC database connection.
I want a small piece of code, probably a login page code that verifies the username from a OpenOffice database (.odb) file. I am particular to know the driver name, etc. If possible give the code using JNDI loopkup.
Thanks in advance,
Parasou.Sure no problem.
Please stand by while I do your work for you. -
Any reported problems using jdbc over a WAN?
If im trying to connect to a Database that's on a WAN will I experience any issues in using jdbc to connect and execute queries to that database?
I know problems would come up if my wan network is slow, but has jdbc been able to handle long distance database queries? timeout values?but why?
is it because of security? If a company had a database with your personal info hanging out on the Web for anyone to query without any validation or security, how would you feel about it?
design pattern issues? It's just good layered design.
just doesnt make sense?Not in my opinion.
have u experienced/heard of any problems of
connecting to a database over a WAN and executing
queries?You don't say anything about who the client is. If the database is behind a firewall, outside clients shouldn't be able to access the port where the listener is running. Only port 80 should be open on that firewall.
So you either write a servlet that listens on port 80 for HTTP requests from a browser-based client OR you ask your firewall admin to punch a hole in the firewall and open up the port on which your database is listening for queries and use a Swing client.
If s/he agrees to do it, quit immediately. It means your company doesn't know anything about security.
% -
A very surprise problem about JDBC and connection pool
I occur a very problem about JDBC and connection pool on Weblogic Platform
8.1.
There is a table in Oracle
Table
Name: t1
id varchar2(5);
content clob;
id is primary key.
If I use a connection pool to connect to Oracle,like following program:
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("cgOracleDataSource");
con = ds.getConnection();
then following program will throw a ClassCastException
String sql = "select content from t1 where id = ?";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1,"001");
oracle.sql.CLOB clob = (oralce.sql.CLOB)rs.getClob("content") //this
statement will throw ClassCastException
but if I use JNDI to connect to Oracle,like following program, then those
program above is ok
private String dbdriver="oracle.jdbc.driver.OracleDriver";
private String dburl="jdbc:oracle:thin:@192.168.7.148:1521:ep";
private String username="ep";
private String password="epuser";
Class.forName(dbdriver);
conn = DriverManager.getConnection(dburl, username, password);
conn.setAutoCommit(false);
On the contrary, if I use JNDI to connect to Oracle, following program will
throw ClassCastException
weblogic.jdbc.vendor.oracle.OracleThinClob clob =
(weblogic.jdbc.vendor.oracle.OracleThinClob)rs.getClob("content");
but it is fine if I use connection pool to connect to Oracle.
I am confused this problem, who can tell me why?
DanielWhen you are getting connection using datasource lookup from weblogic
connection pool, this connection is internally wrapped and hence you have to
cast it to weblogic.jdbc.vendor.oracle.OracleThinClob which you do and so it
works.
But when you get connection by loading driver straight, you are getting naked
oracle connection. In this case when you cast it to oracle.sql.Clob it works,
as you have seen in your test case.
I hope this explains what is going on with your code.
Thanks,
Mitesh
Daniel wrote:
I occur a very problem about JDBC and connection pool on Weblogic Platform
8.1.
There is a table in Oracle
Table
Name: t1
id varchar2(5);
content clob;
id is primary key.
If I use a connection pool to connect to Oracle,like following program:
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("cgOracleDataSource");
con = ds.getConnection();
then following program will throw a ClassCastException
String sql = "select content from t1 where id = ?";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1,"001");
oracle.sql.CLOB clob = (oralce.sql.CLOB)rs.getClob("content") //this
statement will throw ClassCastException
but if I use JNDI to connect to Oracle,like following program, then those
program above is ok
private String dbdriver="oracle.jdbc.driver.OracleDriver";
private String dburl="jdbc:oracle:thin:@192.168.7.148:1521:ep";
private String username="ep";
private String password="epuser";
Class.forName(dbdriver);
conn = DriverManager.getConnection(dburl, username, password);
conn.setAutoCommit(false);
On the contrary, if I use JNDI to connect to Oracle, following program will
throw ClassCastException
weblogic.jdbc.vendor.oracle.OracleThinClob clob =
(weblogic.jdbc.vendor.oracle.OracleThinClob)rs.getClob("content");
but it is fine if I use connection pool to connect to Oracle.
I am confused this problem, who can tell me why?
Daniel -
JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
I am getting below error when i m trying to access oracle db using oracle 11g client. It works with earlier oracle client versions. how do i resolve this. is there any issue with version of ojdbc6.jar that i am using??? I cant use thin driver since its an old application for which i dont have source files.
Apr 6, 2013 1:00:59 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:262)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at PettyCash.SysDate.getSysSubSys(SysDate.java:232)
at org.apache.jsp.PettyCash.index_jsp._jspService(org.apache.jsp.PettyCash.index_jsp:186)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Code is as follow for reference
import oracle.jdbc.driver.*;
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection ("jdbc:oracle:oci8:@" + database,db_user, db_pass);
eNVIRONMENT VARIABLES set are as follows:
classpath
C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\classes12.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\ojdbc6.jar;
JAVA_HOME
C:\Program Files\Java\jdk1.5.0_04
PATH
C:\Program Files\Java\jdk1.5.0_04\bin
ORACLE_HOME
D:\Oracle11\product\11.2.0\client_1\BINApr 8, 2013 5:24:06 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.abc.index_jsp._jspService(org.apache.jsp.abc.index_jsp:280)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595) -
Memory leak when using database connectivity toolset and ODBC driver for MySQL
The "DB Tools Close Connection VI" does not free all the memory used when "DB Tools Open Connection VI" connects to "MySQL ODBC Driver 3.51".
I have made a small program that only opens and close the connection that I run continously and it's slowly eating all my memory. No error is given from any of the VI's. (I'm using the "Simple Error Handler VI" to check for errors.)
I've also tried different options in the DSN configuration without any results.
Attachments:
TestProgram.vi 16 KB
DSNconfig1.jpg 36 KB
DSNconfig2.jpg 49 KBAlso,
I've duplicated the OPs example: a simple VI that opens and closes a connection. I can say this definately causes a memory leak.
Watching the memory:
10:17AM - 19308K
10:19AM - 19432K
10:22AM - 19764K
10:58AM - 22124K
Regards,
Ken
Attachments:
OpenCloseConnection.vi 13 KB -
Unable to connect SQLState=IM004 ODBC Driver Manager] Driver's SQLAllocHand
Hi All,
When I have tried to create dsn connection it start throwing the following error,
do you have any idea how to resolve this..
Unable to connect SQLState=IM004 ODBC Driver Manager] Driver's SQLAllocHandInstall an updated version of the Microsoft Data Access Components (MDAC) from Microsoft @ <http://www.microsoft.com/data>. The version of the ODBC Driver Manager on the failing machine isn't aware that ODBC 3.51 is a valid version of the protocol.
Justin -
Problem using Jdbc-Odbc Bridge
Hi,
I am using Java 2 SDK and I am trying to access MS Access database on my machine using Jdbc-Odbc bridge. I have set up the DSN in ODBC. But I get the following error when I run my program -
'No Suitable Driver'
Here's my code snippet-
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
String dsn = "jdbc:odbc:DriverInfoDB";
Connection con = DriverManager.getConnection(dsn,"","");
con.setAutoCommit(false);
Statement stmt;
String query = null; // SQL select string
ResultSet rs; // SQL query results
stmt = con.createStatement();
.....etc etc...
Where is the error in this code??
Help Needed!!
Thanks
Vivek.try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dsn,"guest","guest");
OR DriverManager.getConnection(dsn);
System.out.println("Conection's opened");
catch(ClassNotFoundException cnfe)
System.err.println(cnfe);
catch(SQLException sqle)
System.err.println(sqle);
try that code and double check you DSN Name . it's a good practice to greate a system DSN.
i hope that helps.
FEEL FREE TO ASK. WON'T BITE U
ABDUL -
Serious problem of jdbc-mysql connectivity using tomcat
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">
<!-- 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 -->
<!-- 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.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="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>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<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>
<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">
<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-cl ***>
<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>
<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>
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<!-- The mapping for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<mime-mapping>
<extension>abs</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ai</extension>
<mime-type>application/postscript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aif</extension>
<mime-type>audio/x-aiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aifc</extension>
<mime-type>audio/x-aiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aiff</extension>
<mime-type>audio/x-aiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>aim</extension>
<mime-type>application/x-aim</mime-type>
</mime-mapping>
<mime-mapping>
<extension>art</extension>
<mime-type>image/x-jg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>asf</extension>
<mime-type>video/x-ms-asf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>asx</extension>
<mime-type>video/x-ms-asf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>au</extension>
<mime-type>audio/basic</mime-type>
</mime-mapping>
<mime-mapping>
<extension>avi</extension>
<mime-type>video/x-msvideo</mime-type>
</mime-mapping>
<mime-mapping>
<extension>avx</extension>
<mime-type>video/x-rad-screenplay</mime-type>
</mime-mapping>
<mime-mapping>
<extension>bcpio</extension>
<mime-type>application/x-bcpio</mime-type>
</mime-mapping>
<mime-mapping>
<extension>bin</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>bmp</extension>
<mime-type>image/bmp</mime-type>
</mime-mapping>
<mime-mapping>
<extension>body</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cdf</extension>
<mime-type>application/x-cdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cer</extension>
<mime-type>application/x-x509-ca-cert</mime-type>
</mime-mapping>
<mime-mapping>
<extension>class</extension>
<mime-type>application/java</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cpio</extension>
<mime-type>application/x-cpio</mime-type>
</mime-mapping>
<mime-mapping>
<extension>csh</extension>
<mime-type>application/x-csh</mime-type>
</mime-mapping>
<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dib</extension>
<mime-type>image/bmp</mime-type>
</mime-mapping>
<mime-mapping>
<extension>doc</extension>
<mime-type>application/msword</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dtd</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dv</extension>
<mime-type>video/x-dv</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dvi</extension>
<mime-type>application/x-dvi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>eps</extension>
<mime-type>application/postscript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>etx</extension>
<mime-type>text/x-setext</mime-type>
</mime-mapping>
<mime-mapping>
<extension>exe</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gtar</extension>
<mime-type>application/x-gtar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gz</extension>
<mime-type>application/x-gzip</mime-type>
</mime-mapping>
<mime-mapping>
<extension>hdf</extension>
<mime-type>application/x-hdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>hqx</extension>
<mime-type>application/mac-binhex40</mime-type>
</mime-mapping>
<mime-mapping>
<extension>htc</extension>
<mime-type>text/x-component</mime-type>
</mime-mapping>
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>hqx</extension>
<mime-type>application/mac-binhex40</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ief</extension>
<mime-type>image/ief</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jad</extension>
<mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jar</extension>
<mime-type>application/java-archive</mime-type>
</mime-mapping>
<mime-mapping>
<extension>java</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jnlp</extension>
<mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpe</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpeg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jsf</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jspf</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>kar</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>latex</extension>
<mime-type>application/x-latex</mime-type>
</mime-mapping>
<mime-mapping>
<extension>m3u</extension>
<mime-type>audio/x-mpegurl</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mac</extension>
<mime-type>image/x-macpaint</mime-type>
</mime-mapping>
<mime-mapping>
<extension>man</extension>
<mime-type>application/x-troff-man</mime-type>
</mime-mapping>
<mime-mapping>
<extension>me</extension>
<mime-type>application/x-troff-me</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mid</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>midi</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mif</extension>
<mime-type>application/x-mif</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mov</extension>
<mime-type>video/quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>movie</extension>
<mime-type>video/x-sgi-movie</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp1</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp2</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp3</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpa</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpe</extension>
<mime-type>video/mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpeg</extension>
<mime-type>video/mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpega</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpg</extension>
<mime-type>video/mpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mpv2</extension>
<mime-type>video/mpeg2</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ms</extension>
<mime-type>application/x-wais-source</mime-type>
</mime-mapping>
<mime-mapping>
<extension>nc</extension>
<mime-type>application/x-netcdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>oda</extension>
<mime-type>application/oda</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pbm</extension>
<mime-type>image/x-portable-bitmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pct</extension>
<mime-type>image/pict</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pgm</extension>
<mime-type>image/x-portable-graymap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pic</extension>
<mime-type>image/pict</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pict</extension>
<mime-type>image/pict</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pls</extension>
<mime-type>audio/x-scpls</mime-type>
</mime-mapping>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pnm</extension>
<mime-type>image/x-portable-anymap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pnt</extension>
<mime-type>image/x-macpaint</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ppm</extension>
<mime-type>image/x-portable-pixmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ppt</extension>
<mime-type>application/powerpoint</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ps</extension>
<mime-type>application/postscript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>psd</extension>
<mime-type>image/x-photoshop</mime-type>
</mime-mapping>
<mime-mapping>
<extension>qt</extension>
<mime-type>video/quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>qti</extension>
<mime-type>image/x-quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>qtif</extension>
<mime-type>image/x-quicktime</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ras</extension>
<mime-type>image/x-cmu-raster</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rgb</extension>
<mime-type>image/x-rgb</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rm</extension>
<mime-type>application/vnd.rn-realmedia</mime-type>
</mime-mapping>
<mime-mapping>
<extension>roff</extension>
<mime-type>application/x-troff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rtf</extension>
<mime-type>application/rtf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rtx</extension>
<mime-type>text/richtext</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sh</extension>
<mime-type>application/x-sh</mime-type>
</mime-mapping>
<mime-mapping>
<extension>shar</extension>
<mime-type>application/x-shar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>smf</extension>
<mime-type>audio/x-midi</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sit</extension>
<mime-type>application/x-stuffit</mime-type>
</mime-mapping>
<mime-mapping>
<extension>snd</extension>
<mime-type>audio/basic</mime-type>
</mime-mapping>
<mime-mapping>
<extension>src</extension>
<mime-type>application/x-wais-source</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sv4cpio</extension>
<mime-type>application/x-sv4cpio</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sv4crc</extension>
<mime-type>application/x-sv4crc</mime-type>
</mime-mapping>
<mime-mapping>
<extension>swf</extension>
<mime-type>application/x-shockwave-flash</mime-type>
</mime-mapping>
<mime-mapping>
<extension>t</extension>
<mime-type>application/x-troff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tar</extension>
<mime-type>application/x-tar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tcl</extension>
<mime-type>application/x-tcl</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tex</extension>
<mime-type>application/x-tex</mime-type>
</mime-mapping>
<mime-mapping>
<extension>texi</extension>
<mime-type>application/x-texinfo</mime-type>
</mime-mapping>
<mime-mapping>
<extension>texinfo</extension>
<mime-type>application/x-texinfo</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tif</extension>
<mime-type>image/tiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tiff</extension>
<mime-type>image/tiff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tr</extension>
<mime-type>application/x-troff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>tsv</extension>
<mime-type>text/tab-separated-values</mime-type>
</mime-mapping>
<mime-mapping>
<extension>txt</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ulw</extension>
<mime-type>audio/basic</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ustar</extension>
<mime-type>application/x-ustar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xbm</extension>
<mime-type>image/x-xbitmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xht</extension>
<mime-type>application/xhtml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/xhtml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xml</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xpm</extension>
<mime-type>image/x-xpixmap</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xwd</extension>
<mime-type>image/x-xwindowdump</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wav</extension>
<mime-type>audio/x-wav</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg</extension>
<mime-type>image/svg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svgz</extension>
<mime-type>image/svg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>vsd</extension>
<mime-type>application/x-visio</mime-type>
</mime-mapping>
<mime-mapping>
<!-- Wireless Bitmap -->
<extension>wbmp</extension>
<mime-type>image/vnd.wap.wbmp</mime-type>
</mime-mapping>
<mime-mapping>
<!-- WML Source -->
<extension>wml</extension>
<mime-type>text/vnd.wap.wml</mime-type>
</mime-mapping>
<mime-mapping>
<!-- Compiled WML -->
<extension>wmlc</extension>
<mime-type>application/vnd.wap.wmlc</mime-type>
</mime-mapping>
<mime-mapping>
<!-- WML Script Source -->
<extension>wmls</extension>
<mime-type>text/vnd.wap.wmlscript</mime-type>
</mime-mapping>
<mime-mapping>
<!-- Compiled WML Script -->
<extension>wmlscriptc</extension>
<mime-type>application/vnd.wap.wmlscriptc</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wrl</extension>
<mime-type>x-world/x-vrml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>Z</extension>
<mime-type>application/x-compress</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z</extension>
<mime-type>application/x-compress</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zip</extension>
<mime-type>application/zip</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
after all this i have taken a jsp page whose code is here:
(the mysql database used is named as "testdb" and the table name is "user" which is having fields name,password and id)
<html>
<head>
<title>DB Test</title>
</head>
<body>
<%
TestSQLLoad tst = new TestSQLLoad ( );
tst.init();
%>
<h2>Results</h2>
User <%= tst.getUser() %>
Pwd <%= tst.getPassword() %>
Id <%= tst.getID() %>
</body>
</html>
and placed it in to the Tomcat 5.5\webapps\tomcat-docs\testdb directory and saved as test-db.jsp
when i run this page on the browser i get a lot may errors stating
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.4 logs.
AND NOW WHEN just to get rid of such errords i try to include a statement
<%@ page import="pkg.TestSQLLoad" %> in the jsp page code (and also place the MySQLLoad.class file in a folder called pkg and place it in the same directory where the jsp page is )and make it look like
<html>
<head>
<%@ page import="pkg.TestSQLLoad" %>
<title>DB Test</title>
</head>
<body>
<%
TestSQLLoad tst = new TestSQLLoad ( );
tst.init();
%>
<h2>Results</h2>
User <%= tst.getUser() %>
Pwd <%= tst.getPassword() %>
Id <%= tst.getID() %>
</body>
</html>
now when i run it i get the following errors:
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported. pkg.TestSQLLoad resolves to a package
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
in response to the above error i have even tried placing the MySQLLoad.class directly in the testdb folder along with the jsp page without keeping it in a package named pkg and then importing directly as <@page import="MySQLLoad" %>
that too gave me the following errors
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
The import TestSQLLoad cannot be resolved
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 12 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
and if i do not use the statement <%@ page import="MySQLLoad"%> then also i get the errors like
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 11 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
An error occurred at line: 11 in the jsp file: /testdb/test-db.jsp
Generated servlet error:
TestSQLLoad cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
THE 2nd Method:
in my second method i did the same changes in the web.xml and server.xml
then i took a jsp page with the following code:
<%@ page import="javax.sql.*,java.sql.*,javax.naming.*,com.mysql.jdbc.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> trial doc </TITLE>
</HEAD>
<BODY>
<h1>Trial Document</h1>
<% InitialContext context=new InitialContext( );
DataSource dataSource=(DataSource) context.lookup("java:comp/env/jdbc/testdb");
Connection conn=dataSource.getConnection();
Statement stmt=conn.createStatement();
ResultSet rset=stmt.executeQuery("select * from user");
if (rset.next()){
%>
<table width="100%" border="1">
<tr align="left">
<th>name</th> <th>password</th><th>id</th>
</tr>
<%
do {
%>
<tr><td> <%=rset.getString(1)%> </td>
<td><%=rset.getString(2) %></td>
<td><%=rset.getString(3) %></td></tr>
<%
} while (rset.next());
%>
</table>
<%
} else{
%>
No results from query
<%
rset.close();
stmt.close();
conn.close();
context.close();
%>
</BODY>
</HTML>
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 15 in the jsp file: /testdb/Big1.jsp
Generated servlet error:
The type Connection is ambiguous
An error occurred at line: 15 in the jsp file: /testdb/Big1.jsp
Generated servlet error:
The type Statement is ambiguous
An error occurred at line: 15 in the jsp file: /testdb/Big1.jsp
Generated servlet error:
The type ResultSet is ambiguous
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.j ava:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Cthanx for ur response
as u said that the problem is more of a jsp page not getting compiled....
me also pointed towards the similar situation providing all the surrounding situations
which i have met and gone through
i m still thinking that problem may b in the tomcat's server.xml and web.xml as well
so better if u plz guide me in that regard
regards,
kuldeep -
I'am using 9iAS R2 and I have a entity bean using a DataSource with out any problem, but I also have a client program using the same datasource. I can lookup the datasource without any problems, I get a connection, but when I try to createStatement() on the connection I get an Exception see below.
I hope some one can help me!
Regards
Morten
java.lang.NullPointerException
at com.evermind.sql.OrionPooledDataSource.addUsedConnection(OrionPooledDataSource.java:539)
at com.evermind.sql.OrionPooledDataSource.getPooledInstance(OrionPooledDataSource.java:290)
at com.evermind.sql.OrionCMTConnection.setConnection(OrionCMTConnection.java:189)
at com.evermind.sql.OrionCMTConnection.intercept(OrionCMTConnection.java:127)
at com.evermind.sql.FilterConnection.getMetaData(FilterConnection.java:75)
at com.evermind.sql.FilterConnection.getMetaData(FilterConnection.java:76)
at dk.modulus.regelmaskine.RegelParamDAO.getRegelParametre(RegelParamDAO.java:33)Hi Morten,
Have you tried running OC4J in "debug" mode? This web page has more details:
http://kb.atlassian.com/content/atlassian/howto/orionproperties.jsp
You may also like to try "P6Spy"
http://www.theserverside.com/home/thread.jsp?thread_id=8337
And here is a web page from Oracle's "Technet" site regarding debugging
OC4J:
http://otn.oracle.com/tech/java/oc4j/htdocs/oc4j-logging-debugging-technote.html
Hope this helps you.
Good Luck,
Avi. -
Cannot connect MS SQL Server2005 by using JDBC(JNDI) connection
Hi all,
I met a problem when I was trying to create a JDBC(JNDI) connection in crystal report 2008, the following error dialog shows up, it said:
Database Connector Error: 'SQL Exceptions: [SQL State:] S1000 [Error Message:] [Microsoft][SQL Native Client]Connection is busy with results for another command'
here is the steps how to reproduce this problem:
1) create a DSN(Data source name) in ODBC Data Source Administrator dialog, suppose the DSN is test
(and the DSN test show it works well)
2) start up Crystal Report 2008, click New to create a new report, the Standard Report Creation Wizard show up
3) expand Create New Connection node, then double click JDBC(JNDI) note
4) the JDBC (JNDI) dialog shows up, chooose JDBC Connection in the dialog, and fill the empty fields with:
Connection URL: jdbc:odbc:test
Database Classname:sun.jdbc.odbc.JdbcOdbcDriver
5) click next, it comes to the next pannel, and fill the empty fields with:
Database: MyTestDB
UserID: sa
Password: sa
6) then click Finish buttion.
7) a new connection is created, but when I expand the new created connection, an error dialog shows up
Database Connector Error: 'SQL Exceptions: [SQL State:] S1000 [Error Message:] [Microsoft][SQL Native Client]Connection is busy with results for another command'
does anyone knows what's wrong with my setting? any help would be appreciated.
Best Regards
Tian-liangHi Tian-liang,
Try using Microsofts JDBC driver rather than Suns. Also search these forums, other have run into the same issue.
Thank you
Don -
Problem using JDBC driver with JSP
Hi, I am trying to connecto to my mysql server via a JSP page, but it seems that there is a problem with the driver call or something in my configuration that unables me to connect. I have the mysql-connector-java-3.0.7-stable driver.
This is how my classpath looks like:
CLASSPATH=/home/hooper/Sources/mysql-connector-java-4.0.7-stable/lib:/home/hooper/Sources/mysql-connector-java-3.0.7-stable/com:/home/hooper/Sources/mysql-connector-java-3.0.7-stable/mysql-connector-java-3.0.7-stable-bin.jar:/usr/java/j2sdk1.4.1_02:.:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/usr/java/j2sdk1.4.1_02
And this is my JSP page code:
<%@ page language="java" import= "java.sql.*"%>
<%
Connection con = null;
String userName = "hooper";
String password = ""; //No password
String url = "jdbc:mysql://localhost/test";
//Load the Driver class file
Class.forName("com.mysql.jdbc.Driver");
//Make a connection to the MySQL database
con = DriverManager.getConnection (url, userName, password);
out.println ("Database connection established");
if (con != null){
//Close the connection
con.close();
%>
And this is the error I get from Tomcat4.1.18:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: com.mysql.jdbc.Driver
root cause
javax.servlet.ServletException: com.mysql.jdbc.Driver
I hope someone can help me with this.
Thanks,
LuisHi..
Try using this way
String userName = "hooper";
String password = ""; //No password
String url = "jdbc:mysql://localhost:3306/test";
Class.forName("org.gjt.mm.mysql.Driver");
try to download the driver for mysql and add it to your classpath
Hope this works
Regd
Vasi -
How to use JDBC to connect Oracle databse
Hi
I try to connect the oracle databse by using JDBC. But I not sure whether is it correct or not because I learnt from the documentation provided by WWW.JAVA.SUN.
I have create a ODBC DSN file call TKS username/password : tem/manager
then I download the source code and enhance a bit as following :
import java.sql.*;
public class CreateCoffees
public static void main(String args[])
String url = "jdbc:oracle:thin:tem/manager@(
description=(address_list=(
address=(protocol=tcp)
(host=192.9.200.8)(port=1521)))(source_route=yes)
(connect_data=(sid=tks)))";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(java.lang.ClassNotFoundException e)
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
try {
con = DriverManager.getConnection(url, "tem", "manager");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
catch(SQLException ex)
{ System.err.println("SQLException: " + ex.getMessage());
After that I saved the file as CreateCoffees.java and compiled it
D:\KLTAY\JAVA>javac CreateCoffees.java
CreateCoffees.java:6: unclosed string literal
String url = "jdbc:oracle:thin:tem/manager@(
^
CreateCoffees.java:10: unclosed string literal
(connect_data=(sid=tks)))";
^
CreateCoffees.java:30: cannot resolve symbol
symbol : variable con
location: class CreateCoffees
con = DriverManager.getConnection(url, "tem", "manager");
^
CreateCoffees.java:31: cannot resolve symbol
symbol : variable con
location: class CreateCoffees
stmt = con.createStatement();
^
CreateCoffees.java:34: cannot resolve symbol
symbol : variable con
location: class CreateCoffees
con.close();
^
5 errors
Please give some advise.Thanks
best regards,
TayString url = "jdbc:oracle:thin:tem/manager@(
description=(address_list=(
address=(protocol=tcp)
(host=192.9.200.8)(port=1521)))(source_route=yes)
(connect_data=(sid=tks)))";
After that I saved the file as CreateCoffees.java and
compiled it
D:\KLTAY\JAVA>javac CreateCoffees.java
CreateCoffees.java:6: unclosed string literal
String url = "jdbc:oracle:thin:tem/manager@(
^
CreateCoffees.java:10: unclosed string literal
(connect_data=(sid=tks)))";
^I would suggest putting all code between the quotesj(") on one line and then attempting to recompile. -
How to use JDBC to connect informix database
Dear all,
I want my client application to connect informix database by using JDBC. The JDBC driver has been installed successfully in the client computer (Win2000). The informix 5.0 resides the a Unix server named "dbserver". The following is my java program.
========================
import java.sql.*;
import java.awt.event.*;
public class Application1 {
public static void main(String[] args) {
Connection conn;
try
Class.forName("com.informix.jdbc.IfxDriver");
catch (Exception e)
System.out.println("Error "+e.getmessage());
e.printStackTrace();
return;
System.out.println("It is ok");
try
conn = DriverManager.getConnection("jdbc:informix-sqli://dbserver:1526:INFORMIXSERVER=dbserver;username=test;password=******");
catch (SQLException e)
System.out.println("ERROR ."+e.getMessage());
e.printStackTrace();
return;
System.out.println("All is fine");
===========================
However, the error appears mentioning "Attempt to connect to database server (dbserver) failed." I don't know what the problem is because my informix database server is exactly "dbserver".
Kindly need help from you guys. Thanks in advance.
KevinHi,
Plz try this (instead of 'username' use 'user') ...
DriverManager.getConnection("jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver;user=test;password=*****");
or this (pass the username and password as params)....
DriverManager.getConnection( "jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver" , "test" , "*****" );
Hope this helps
ssa.
>
I want my client application to connect informix
database by using JDBC. The JDBC driver has been
installed successfully in the client computer
(Win2000). The informix 5.0 resides the a Unix server
named "dbserver". The following is my java program.
========================
import java.sql.*;
import java.awt.event.*;
public class Application1 {
public static void main(String[] args) {
Connection conn;
try
Class.forName("com.informix.jdbc.IfxDriver");
catch (Exception e)
System.out.println("Error "+e.getmessage());
e.printStackTrace();
return;
System.out.println("It is ok");
try
conn =
onn =
DriverManager.getConnection("jdbc:informix-sqli://dbser
er:1526:INFORMIXSERVER=dbserver;username=test;password=
catch (SQLException e)
System.out.println("ERROR ."+e.getMessage());
e.printStackTrace();
return;
System.out.println("All is fine");
===========================
However, the error appears mentioning "Attempt to
connect to database server (dbserver) failed." I don't
know what the problem is because my informix database
server is exactly "dbserver".
Kindly need help from you guys. Thanks in advance.
Kevin
Maybe you are looking for
-
How to control prsence of fields in saveas method.urgent please
I Created a template form with some buttons ,textfields and dropdown fields. i kept saveas button if user clicks and saves the file as another name . i want to remove apprence of buttons and drop down buttons etcc.. i tried dataroot.Transmittal_pdf.B
-
Acrobat X Pro - Converting web pages
Windows/IE8 When you use "Convert to PDF" if there is a background border color on some web pages it is not captured. The page crops to eliminate the border. The "Use Web page background color" has no effect on this. The background color is captur
-
Hello, I looking for a bapi to assign open reservation of a process order to handling unit (like tansaction copawa). Thanks.
-
HI, In co01 we are creating production order. IN this we have thegoods reciept sub screen, in here we have the stock type field (list box) in this list 1)unrestricted to use 2)Quality inspection 3)Blocked Stock in this list we need another option
-
Afficher la grille de pixel avec les nombres
Bonsoir à tous, sous Photoshop CS6 en français, jaimerais afficher la grille de pixel avec le nombre de pixel comme ceci: http://img.funky-emu.net/uploads/121639IMG-06042013-233654.png Vous avez le nombre de pixel en haut. Merci