Hello I have been having this issue for hours now. If anyone can help. It would be priceless.
I have a MS SQL Server installed with a database running on port 1443 with firewall allowing connections. I have set up the pool and the jdbc resources, and have checked it several times. The DataSource name is correct, username, password, etc. in the admin control for glassfish.
I wrote a little application that simply tests the connection.
JSF:
<h:body>
<h:form id="testDSForm">
<h:commandButton value="Test DataSource" action="#{testDS.lookUp}" /><br/><br/>
<h:outputText value="#{testDS.message}" />
</h:form>
</h:body>
import javax.faces.bean.*;
import java.sql.Connection;
import javax.annotation.Resource;
import javax.sql.DataSource;
@ManagedBean
public class TestDS {
private String message;
private Connection dbCon;
@Resource(name="jdbc/sqlserver")
DataSource ds;
public String lookUp() {
try {
message = "";
dbCon = ds.getConnection();
dbCon.close();
message = "DataSource lookup ok";
} catch (Exception e) {
System.err.println("getConnection" + e.getMessage());
message = "DataSource Lookup Failed";
e.printStackTrace();
}
return null;
}
public String getMessage() { return message; }
}
I receive:
WARNING: RAR5038:Unexpected exception while creating resource for pool SQLPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: The connection string contains a badly formed name or value.
WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ SQLPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: The connection string contains a badly formed name or value.
WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: The connection string contains a badly formed name or value.]
SEVERE: getConnectionError in allocating a connection. Cause: Connection could not be allocated because: The connection string contains a badly formed name or value.
SEVERE: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: The connection string contains a badly formed name or value.
when i run
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
dbCon = DriverManager.getConnection(dbURLMS, login, password);
I receive no errors and I can work with the database.
Thanks so much for any help!
[Message sent by forum member 'chardoc89']
http://forums.java.net/jive/thread.jspa?messageID=397848