ds.getConnection hangs indefinitely with tomcat 6 to MSSQL DB - java

I am trying to connect mssql database with my war file deployed on tomcat 6.0.41, java version 1.5.0_22.
Tomcat hangs for indefinite time at the following line of code.
DataSource ds;
this.conn = ds.getConnection();
And also it works fine with Oracle database.
I have tried making changes at tomcat in context.xml file but of no use.
Thanks,

Related

Can`t connect to PostgreSQL database in Pentaho Kettle

I`m trying to connect to my PostgreSQL database. What I create a connection and click the button "Test", I receive an error message. I can connect to this db via pgadmin without any problems, so it is not a connection or credentials issue
I`m using Pentaho kettle 8.3, Windows, java version "1.8.0_231"
Error connecting to database [Name] :org.pentaho.di.core.exception.KettleDatabaseException:
Error occurred while trying to connect to the database
Error connecting to database: (using class org.postgresql.Driver)
Ошибка при попытке подсоединения.
Full error stack: https://pastebin.com/cLiB288e
Try to add postgresql-42.1.1.jar in the /lib folder of PDI, restart the spoon and try again.
i faced 2 issues myself connecting to PostgreSQL few months back and following 2 things helped me
1.add postgres-42.1.1jar file in the 'lib' folder under PDI and restart the spoon.
if the normal JDBC connection convention does not work for you try below tip
while configuring the connection specify host name as follows
{HOST IP}:{HOST PORT}/{instance name}?

What is the correct procedure for adding SQL Server JDBC to GlassFish 3.1.2

I am setting up a test GlassFish Server to learn NetBeans, Java, GlassFish web application development. I was able to do a basic deployment successfully and am moving on to databases.
I am trying to set up a MS SQL Server connection pool in the GlassFish admin. After configuring the datasource as javax.sql.Datasource and setting the properties, it fails to successfully ping the connection.
When I try to ping the connection, I get this error
Ping Connection Pool failed for SQLDB. Class name is wrong or classpath is not set for :
com.microsoft.sqlserver.jdbc.SQLServerDataSource
It looks like the .jar file isn't being loaded. I have placed the sqljdbc4.jar in the glassfish\modules folder.
What is the correct process for setting up a JDBC connection pool for SQL Server?
In case you are using JRE 7 : use JDBC41
in case you are using JRE 8 : use JDBC42
Unzip the exe from the following link : https://www.microsoft.com/en-us/download/confirmation.aspx?id=54671
Paste the jar in the lib folder of glassfish .
Once done define property under connection pool as URL and pass full qualified connection name as : jdbc:sqlserver://localhost\MSSQLSERVER:1433;databasename=AdventureWorks2016;integratedSecurity=true

WAR file deployment not connecting to MySQL

I made a dynamic web project in Eclipse IDE and generated a .war file to uploaded it on tomcat localhost for testing using XAMPP server
I deployed the war file in tomcat manager and all the pages are getting displayed properly.
I have made a few connections for connecting to mysql database for insertions. But the deployed does not interacts with the XAMPP phpmyadmin
I checked the username and password for connection string in my java program and made changes in config.inc.php file accordingly in phpmyadmin folder
All the database operations are being executed inside the eclipse environment but when I deploy the war file it is not executing.
Check your XAMPP Apache server configuration..
Go to, config -> phpMyAdmin(config.inc.php) and check this username & password related to Your Java Program.
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = ''
If Mysql has any different password, Change root password to empty.

Java DB doesn't run without NetBean [duplicate]

I have a Java application, which uses Apache Derby. Using Eclipse Export option, I exported it as JAR file. When I am running Eclipse, and the server is connected to port 1527, the JAR executes correctly.
However when eclipse is closed, (and the server is not connected to 1527) on executing jar, i get this error
java.sql.SQLNonTransientConnectionException: java.net.ConnectException
: Error connecting to server localhost on port 1527 with message
Connection refused.
This is understandable. But i want to distribute the JAR. So is there a way to start the server programmatically, whenever JAR is executed?
You can start the NetworkServer programmatically:
NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("myhost"),1621)
serverControl.shutdown();
Simplest is to use embedded Derby
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
conn = DriverManager.getConnection("jdbc:derby:" + DATA_STORE + ";create=true");
You need to start the server programmatically.
How this is done is documented in the manual:
http://db.apache.org/derby/docs/10.8/adminguide/tadminconfig814963.html

Could not connect to New SQL Server in eclipse

Connecting/pinging a database in eclipse gives me error:
My software is: MySql Server 5.5.12, Connector/J 5.1.17, Eclipse IDE for Java EE Developers v. 1.4.0.20110615-0550.
Logging from console or phpmyadmin works ok.
Here is also screenshot of connection settings:
Any suggestions about this error?
You are loading a MSSQL driver, but you are running a MySQL server.
http://www.mysql.com/products/connector/
change the driver to Mysql driver 5.0 and it will connect properly

Categories