Unable to get connection, DataSource invalid - Netbeans, MySQL - java

I'm following the tutorial of Netbeans site:
https://netbeans.org/kb/docs/web/mysql-webapp.html
everything was working fine until this step: Implementing JSTL code STEP 4 where the list should be displayed I get the following error:
javax.servlet.ServletException: javax.servlet.jsp.JspException:
Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused."
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException :
Error connecting to server localhost on port 1527 with message Connection refused."
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.
I suppose netbeans still tries to connect to the Derby DB. How can i change it to MySQL DB?
I am using Java EE7, MySQL, Netbeans, Glassfish 4

The stack trace indicates that the MySQL DB is not running on port 1527
See https://netbeans.org/kb/docs/ide/mysql.html

Use GlassFish Server Open Source Edition 3.x and Java EE Version 5 or 6
Then it works.

I had a similar problem and I solved it using a different approach. I changed the settings in the glassfish-web.xml file found in IFPWAFCAD/WebPages/WEB-INF folder. The following settings worked for me for this particular tutorial https://netbeans.org/kb/docs/web/mysql-webapp.html:
Resource Reference name: jdbc/IFPWAFCAD
JNDI Name: jdbc/IFPWAFCAD
Principal Name: root
Principal Password: nbuser
These settings will work for this particular tutorial - I used glassfish 4 - and Java EE 5. No need to install glassfish 3

Related

GlassFish HTTP Status 500 - Internal Server Error(JSTL)

When I try to run my Web Application using JSP, the GlassFish server returns the follow message:
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 5.1.0 logs.
GlassFish Server Open Source Edition 5.1.0
And I don't knhow what to do. I think the error is connected to Can't find javax.servlet.jsp.jstl.jar library in glassfish server
You will need to make the MySQL JDBC jar file available to Glassfish.
https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-usagenotes-glassfish-config.html
So I have figured it out, all I had to do was to set the datasource class name to
com.mysql.cj.jdbc.MysqlDataSource
since I was using MySql connetor J version 8.
Initally I had set the datasource class name to
com.mysql.jdbc.jdbc2.optional.MySqlDataSource

Wildfly Datasource via VPN to MS SQL Server

currently, I am facing some odd behavior.
I have a Java EE Web Application that I am deploying to a wildfly server. This Java EE Application needs a database to which we need to connect via vpn. We are using OpenVPN. When I am using SSMS I have no problems connecting to the database. When I am using pure JDBC, there also is no problem.
But if I am creating a datasource in wildfly (and I am using the exact same jdbc connection url) it does not working. I am using the wildfly admin ui and click the test-button.
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 10.1.115.51, port 1433 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
I mean, the stack trace is pretty clear. However, the connection should be possbile as I connect via ssms and pure jdbc. Just wildfly datasource is not working.
Furhtermore, I have installed a MS SQL Server on the same mashine the wildfly is running on and using this MS SQL instance the datasource is working fine.
The jdbc url connection url is the following:
jdbc:sqlserver://< ip >:1433;databaseName=projdat;user= ** ;password= **
I have compared the jdbc url connection urls multiple times. Both in the pure jdbc and in the datasource they are the same.
Does anybody have any ideas? Is possible that I need to configure openvpn in a special way that wildfly can connect or do I need to configure Wildfly to be able to connect via vpn. Or do I have to configure the MS SQL Server in special way?
Version of MS SQL Server: 12
Version Wildfly: 19.0.0.Final
SQL Server driver: mssql-jdbc-8.2.2.jre8.jar
I apreciate any hint or advise.
Apparently, I was using an older version of Wildfly (in fact, it was wildfly 16). After I upgraded to Wildfly 19, it is now working. However, I have no clue why it was not working with wildfly 16.

Error using Rational Asset Manager with Oracle 11g

Using Rational Asset Manager 7.5.4.1 version with Oracle 11.g on WAS 8.5.5.13 I am getting following oracle error?
While we see the logs we get following SQL error code.
SQL Error Code is 17008 SQL State is :08003
Other log trace says like below.
java.nio.channels.ClosedByInterruptException
java.sql.SQLRecoverableException: Closed Connection
com.ibm.websphere.ce.cm.StaleConnectionException: Closed Connection
com.ibm.websphere.ce.cm.StaleConnectionException: IO Error: Socket read interrupted
What could be the reason?
The error usually is caused due to network issue or firewall issues.
To root cause and eliminate those:
1. You can check AWR and other connectivity reports
2. Ping works between app server and DB host
3. Required configurations for sqlnet.ora parameters time out are set correctly.
If none of them fix the issue, it worth to check jdbc jar file and its version.
In this case i think solution is to use jdbc6.jar and checking if there is any mismatch in the version of the jar that is presently used.

Embedded Database project

So I received this error message:
java.sql.SQLNonTransientConnectionException: java.net.ConnectException
: Error connecting to server localhost on port
What does this even mean? I searched it up and what I found was that I never created an embedded database but rather a server? Regardless, the steps I followed were exact in order to create an embedded database.

Error while opening JDBC connection from Weblogic server 10.3.5

I developed an ADF application in Jdeveloper11.1.1.7 and deployed it in Weblogic server 10.3.5. From Jdeveloper every thing working perfectly But from weblogic server I can see in the server stack the error (Error while opening JDBC connection, Caused by null password given; logon denied) here is part of exception thrown:
Exception inside -------.jbo.DMLException: JBO-26061: Error while opening JDBC connection.
oracle.jbo.DMLException: JBO-26061: Error while opening JDBC connection.
at oracle.jbo.server.ConnectionPool.createConnection(ConnectionPool.java:207)
at oracle.jbo.server.ConnectionPool.instantiateResource(ConnectionPool.java:166)
at oracle.jbo.pool.ResourcePool.createResource(ResourcePool.java:583)
at oracle.jbo.pool.ResourcePool.useResource(ResourcePool.java:316)
at oracle.jbo.server.ConnectionPool.getConnectionInternal(ConnectionPool.java:102)
at oracle.jbo.server.ConnectionPool.getConnection(ConnectionPool.java:67)
.......................................
.......................................
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.sql.SQLException: ORA-01005: null password given; logon denied
I did what is suggested in the following links:
My Learning's # Work - by Lakshmipathi Kakarla: ORA-01005: null password given
Extending WebLogic Server for ADF Applications Step 23
I added Djps.app.credential.overwrite.allowed=true to the JAVA_PROPERTIES and EXTRA_JAVA_PROPERTIES and restart the server but the issue is not resolved. Any idea what goes wrong? Please note that the file (setDomainEnv) in the bin folder for the weblogic domain contains more that setting to the previous variables, the change I did is always rise in the first set of the variables
Attached where exactly the command is added in setDomainEnv is it the right place to add? what is missing?
I was getting this error:
oracle.jbo.DMLException: JBO-26061: Error while opening JDBC connection.
Went here, said to alter AppModule configuration. So... right click on AppModule->Configurations->Edit
Connection Type for me was set to "JDBC Datasource". I set it to "JDBC URL". Note:
For some reason the JDBC URL may have to be tweaked. Here's mine:
jdbc:oracle:thin:#(description=(address=(host=FULLY_QUALIFIED_HOST)(protocol=tcp)(port=1521))(connect_data=(service_name=ORACLE_SID)(server=DEDICATED)))
It worked. On to the real problem.
Referring to this link:
Error while opening JDBC connection from Weblogic server 10.3.5
problem solved by changing application module configuration form using JDBC URL to using DataSource.

Categories

Resources