My context.xml... -
<Context path="/JNDITest">
-
<Resource name="jdbc/dataSource" auth="Container"
-
type="javax.sql.DataSource"
-
-
driverClassName="org.postgresql.Driver"
-
url="jdbc:postgresql://10.29.33.90:5432/Admin"
-
username="erp"
-
password="iiterp"
-
-
maxIdle="50"
-
maxWait="60000"
-
maxActive="10"/>
-
</Context>
-
My Java Code .... -
Context ctx = new InitialContext();
-
DataSource ds= (DataSource)ctx.lookup("java:/comp/env/jdbc/dataSource");
-
Connection l_con = ds.getConnection();
-
It's working fine when I use Windows, but it's not working when I use Linux.
My Application server is Tomcat.
I mean to say why does it behave in different operating System .. Where I gone wrong ?
10 7198
Is your postgreSQL jar in your classpath on your linux machine?
kind regards,
Jos
If the Jar is not in the classpath then why it runs properly in Windows ?
The jars are kept into the the folder WEB-INF/lib and i am making the war file and deploy it into the server...In Windows the war file is running OK ..but why not in Linux?
This is my another test ............... in Linux Tomcat Server.
My context.xml is ... -
<Resource name="jdbc/EmployeeDB" auth="Container"
-
type="javax.sql.DataSource"
-
description="Employees Database for HR Applications"
-
driverClassName="org.postgresql.Driver"
-
url="jdbc:postgresql://10.29.32.68:5432/Admin"
-
username="erp"
-
password="iiterp"/>
-
In my home.jsp the code snippet is .... -
DriverManager.registerDriver(new org.postgresql.Driver());
-
Connection l_con = DriverManager.getConnection("jdbc:postgresql://10.29.32.68:5432/Admin","erp","iiterp");
-
-
Context ctx = new InitialContext();
-
DataSource ds= (DataSource)ctx.lookup("java:/comp/env/jdbc/EmployeeDB");
-
Connection l_con1 = ds.getConnection();
-
When it runs on Linux Tomcat server it shows an error in line ... - Connection l_con1 = ds.getConnection();
If the jar is not in class path then why it could execute successfully the line ... -
DriverManager.registerDriver(new org.postgresql.Driver());
-
Connection l_con = DriverManager.getConnection("jdbc:postgresql://10.29.32.68:5432/Admin","erp","iiterp");
-
-
Please Help!
Now I could figure out the problem ...
Actually i didn't deploy into the Tomcat server running under Windows. ;)
Actually what happened, i was using Netbeans simply ran the Application and it got into work .. I don't understand how it did run.
But when i deployed the war file into the Window Tomcat Server then the same problem i was having.
Why does it happen .. when i load the Driver class using DriverManager then it looks from the WEB-INF/ib but when i try to get connection using JNDI look then it looks for another directory?
Yeah now it's working i put the driver class into the ext directory.
But still i am waiting for the answer ... why does it behave like differently in two cases ?
@dmjpro
You gave the answer yourself: you didn't deploy on your Windows machine but made NetBeans do all the work for you. Make sure the 'environments' are identical on both computers. btw, don't just put your jars in the /ext directory to make things 'work'; most likely those jars don't belong there. Read this.
kind regards,
Jos
What Environments u telling about ?
And i meant to say why it looks from different locations .. ?
@dmjpro
By equal 'environments' (mind the quotes) I meant: equal Java JRE versions, equal classpaths, equal available jars etc. I don't know what you mean by 'why it looks from different locations"; please elaborate.
kind regards,
Jos
When i try to connect using ... -
DriverManager.registerDriver(new DriverClass());
-
Connection l_con = DriverManager.getConnection(......);
-
Then it looks from WEB-INF/lib but i use JNDI look up then it looks from class path .. I did mean that ... ;)
On tomcat the WEB-INF/lib folder is on the path by default.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Fu Bo Xia |
last post by:
the java.lang.Object.forName method takes a java class name and returns a
Class object associated with that class.
eg. Class myClass = Object.forName("java.lang.String");
by if i only know the...
|
by: Ravi Tallury |
last post by:
Hi
We are having issues with our application, certain portions of it stop
responding while the rest of the application is fine. I am attaching
the Java Core dump. If someone can let me know what...
|
by: JShurmatz |
last post by:
If anyone can shed some light on this problem I would greatly
appreciate it.
I am unsuccessfully trying to use a database connnection retrieved
from a pool configured using Java System Web...
|
by: dinesh prasad |
last post by:
I'm trying to use a servlet to process a form, then send that data to
an SQL server stored procedure. I'm using the WebLogic 8 App. server.
I am able to retrieve database information, so I know my...
|
by: Kent Lewandowski |
last post by:
hi all,
Recently I wrote some stored procedures using java jdbc code
(admittedly my first stab) and then tried to implement the same within
java packages (for code reuse). I encountered...
|
by: astolpho |
last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output:
...
|
by: Ananthu |
last post by:
Hi
I have done all the codings part for connecting mysql server with java application but when i try to compile,the compilation is successful and during execution i get the following message,
...
|
by: Ananthu |
last post by:
Hi
I have done all the codings part for connecting mysql with java in eclipse environment.
Coding Part:
import java.sql.Connection;
import java.sql.DriverManager;
public class...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |