[MonetDB-users] Using DataSource class within MonetDB -- connection error -- cause? fix?
I got lots of good help with my last query. I am trying to access a MonetDB through Sun's Glassfish app server. I am following an example that uses the Java Persistence API and Netbeans 6.0 beta 2 that has some interesting automation to generate code, in particular for configuration file generation that define the jndi context. But my example doesn't work. My code is based on a tutorial I found that uses Derby which is built into Glassfish. I see the errors: TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007)) Server: unknown RAR5038:Unexpected exception while creating resource RAR5117 : Failed to obtain/create connection from connection pool [ jdbc_monetdb_localhost_demoPool ]. Reason : Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused] Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused Error Code: 0 Local Exception Stack: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused I looked at the class MonetDataSource in the JDBC jar file and I see that the constructor for MonetDataSource uses 45123 for the field portNumber. But there is no apparent way to set the portNumber to something else. How do I get MonetDB to listen on this port? It seems that the default port is 50000. Is there a conf setting I can make to get this to work? What is the difference between portNumber here and port value as checked for in the Driver class? Any help appreciated. Jim -- View this message in context: http://www.nabble.com/Using-DataSource-class-within-MonetDB----connection-er... Sent from the monetdb-users mailing list archive at Nabble.com.
jsolderitsch wrote:
I got lots of good help with my last query.
I am trying to access a MonetDB through Sun's Glassfish app server.
I am following an example that uses the Java Persistence API and Netbeans 6.0 beta 2 that has some interesting automation to generate code, in particular for configuration file generation that define the jndi context.
But my example doesn't work. My code is based on a tutorial I found that uses Derby which is built into Glassfish.
I see the errors:
TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007)) Server: unknown RAR5038:Unexpected exception while creating resource RAR5117 : Failed to obtain/create connection from connection pool [ jdbc_monetdb_localhost_demoPool ]. Reason : Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused] Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused Error Code: 0 Local Exception Stack: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused
I looked at the class MonetDataSource in the JDBC jar file and I see that the constructor for MonetDataSource uses 45123 for the field portNumber. But there is no apparent way to set the portNumber to something else.
How do I get MonetDB to listen on this port? It seems that the default port is 50000. Is there a conf setting I can make to get this to work?
What is the difference between portNumber here and port value as checked for in the Driver class?
Any help appreciated.
Jim
I dug into this a little and it seems that if I change the mapi_port to 45123 in the .conf file and then use the port number explicitly in my JDBC connection URL string I can indeed use MonetDB in the same style as I saw in the tutorial. My glassfish example now works. If I leave the mapi_port set as 0, the default port number is used and with JDBC, I did not need to use the port number when I did simple queries from inside netbeans. A side effect is that I need to use a -p option when I use mclient from the command line. Maybe if in my JDBC url, I explicitly used port 50000, could leave the default setting alone? I will try this. Another difficulty was I used a column name (missionNumber) that seemed to cause the code generation for the JPA classes to produce weird effects. I found that I could not use the query: select missionNumber from missionstatus as SQL. I found I needed to use: select "missionNumber" from missionstatus I changed the column name to mission_status and then the generated Java names were as expected. And I could use the query: select mission_number from missionstatus without the quotes. -- View this message in context: http://www.nabble.com/Using-DataSource-class-within-MonetDB----connection-er... Sent from the monetdb-users mailing list archive at Nabble.com.
jsolderitsch wrote:
I got lots of good help with my last query.
I am trying to access a MonetDB through Sun's Glassfish app server.
I am following an example that uses the Java Persistence API and Netbeans 6.0 beta 2 that has some interesting automation to generate code, in particular for configuration file generation that define the jndi context.
But my example doesn't work. My code is based on a tutorial I found that uses Derby which is built into Glassfish.
I see the errors:
TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007)) Server: unknown RAR5038:Unexpected exception while creating resource RAR5117 : Failed to obtain/create connection from connection pool [ jdbc_monetdb_localhost_demoPool ]. Reason : Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused] Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused Error Code: 0 Local Exception Stack: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused
I looked at the class MonetDataSource in the JDBC jar file and I see that the constructor for MonetDataSource uses 45123 for the field portNumber. But there is no apparent way to set the portNumber to something else.
that looks like an old piece of code..with an old default. I guess that it is overwritten later in the process.
How do I get MonetDB to listen on this port? It seems that the default port is 50000. Is there a conf setting I can make to get this to work?
yes, see the documentation in monetdb.conf and the options for mjclient, the java based textual interface.
What is the difference between portNumber here and port value as checked for in the Driver class?
Any help appreciated.
Jim
On 14-11-2007 17:07:39 -0800, jsolderitsch wrote:
Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused] [snip] I looked at the class MonetDataSource in the JDBC jar file and I see that the constructor for MonetDataSource uses 45123 for the field portNumber. But there is no apparent way to set the portNumber to something else.
Oopsie! Legacy! I fixed this in 1.6 Steadfast_p13 which you can pick up from here: http://www.cwi.nl/~fabian/troep/monetdb-1.6-jdbc.jar and http://www.cwi.nl/~fabian/troep/jdbcclient.jar I feel it should be possible to change the port number in the DataSource, but I have no clue how. At least I did not when I implemented the class. It's very shallow, but I'm pleased to hear that it actually works for you in your workarounds.
Fabian Groffen wrote:
On 14-11-2007 17:07:39 -0800, jsolderitsch wrote:
Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused] [snip] I looked at the class MonetDataSource in the JDBC jar file and I see that the constructor for MonetDataSource uses 45123 for the field portNumber. But there is no apparent way to set the portNumber to something else.
Oopsie! Legacy! I fixed this in 1.6 Steadfast_p13 which you can pick up from here:
http://www.cwi.nl/~fabian/troep/monetdb-1.6-jdbc.jar and http://www.cwi.nl/~fabian/troep/jdbcclient.jar
I feel it should be possible to change the port number in the DataSource, but I have no clue how. At least I did not when I implemented the class. It's very shallow, but I'm pleased to hear that it actually works for you in your workarounds.
Thanks for the quick update. Yes, this works now without any special configuration on my part. Setting the port number in the MonetDataSource class to 50000 (the default Monet port) made the difference. Now I don't need to use an explicit port number in my JDBC URL and the DataSource magic being used through Netbeans and Glassfish allow the DB calls to go through successfully. Now I can get back to my real work... -- View this message in context: http://www.nabble.com/Using-DataSource-class-within-MonetDB----connection-er... Sent from the monetdb-users mailing list archive at Nabble.com.
jsolderitsch wrote:
Fabian Groffen wrote:
On 14-11-2007 17:07:39 -0800, jsolderitsch wrote:
Cause: Connection could not be allocated because: Unable to connect (localhost:45123): Connection refused] [snip] I looked at the class MonetDataSource in the JDBC jar file and I see that the constructor for MonetDataSource uses 45123 for the field portNumber. But there is no apparent way to set the portNumber to something else.
Oopsie! Legacy! I fixed this in 1.6 Steadfast_p13 which you can pick up from here:
http://www.cwi.nl/~fabian/troep/monetdb-1.6-jdbc.jar and http://www.cwi.nl/~fabian/troep/jdbcclient.jar
I feel it should be possible to change the port number in the DataSource, but I have no clue how. At least I did not when I implemented the class. It's very shallow, but I'm pleased to hear that it actually works for you in your workarounds.
Thanks for the quick update. Yes, this works now without any special configuration on my part. Setting the port number in the MonetDataSource class to 50000 (the default Monet port) made the difference.
Now I don't need to use an explicit port number in my JDBC URL and the DataSource magic being used through Netbeans and Glassfish allow the DB calls to go through successfully.
Now I can get back to my real work...
OK, now a new problem. Glassfish wants to establish a connection pool on behalf of my deployed web application. I want to access a remote database, not one deployed to localhost. But it looks like code in the MonetDataSource is not equipped to allow non-localhost connections. I see in the class: public class MonetDataSource implements DataSource { public MonetDataSource() { loginTimeout = 0; databaseName = "demo"; hostName = "localhost"; portNumber = 50000; description = "MonetDB database"; driver = new MonetDriver(); } But like portNumber, hostName is not available for substitution. Ideally, shouldn't it be possible for the data source to refer to any host and database name. I can see that the port number may be a problem, but what about the host? Or maybe I don't understand the process here but I started up my remote DB, shutdown the local one, changed the URL for the connection to reference the remote DB, but the deployed application fails because it can't connect to localhost. Any ideas? It's looking like I may need to switch to a DB with more complete javax.sgl.DataSource support. Jim -- View this message in context: http://www.nabble.com/Using-DataSource-class-within-MonetDB----connection-er... Sent from the monetdb-users mailing list archive at Nabble.com.
On 15-11-2007 07:21:35 -0800, jsolderitsch wrote:
OK, now a new problem.
Glassfish wants to establish a connection pool on behalf of my deployed web application.
I want to access a remote database, not one deployed to localhost.
But it looks like code in the MonetDataSource is not equipped to allow non-localhost connections.
I see in the class:
public class MonetDataSource implements DataSource {
public MonetDataSource() { loginTimeout = 0; databaseName = "demo"; hostName = "localhost"; portNumber = 50000; description = "MonetDB database"; driver = new MonetDriver(); }
But like portNumber, hostName is not available for substitution. Ideally, shouldn't it be possible for the data source to refer to any host and database name. I can see that the port number may be a problem, but what about the host?
This is indeed stupid. I will see if I can find how a DataSource is supposed to have these values overridden. Ideally databaseName, hostName and portNumber are specified by the user, as the defaults don't really make sense, apart from the port number maybe.
Or maybe I don't understand the process here but I started up my remote DB, shutdown the local one, changed the URL for the connection to reference the remote DB, but the deployed application fails because it can't connect to localhost.
Any ideas?
The DataSource is just not complete. But if you have any direct pointers on how to improve it, I'm willing to look into it.
It's looking like I may need to switch to a DB with more complete javax.sgl.DataSource support.
Whatever floats your boat.
On 15-11-2007 17:33:34 +0100, Fabian Groffen wrote:
On 15-11-2007 07:21:35 -0800, jsolderitsch wrote:
OK, now a new problem.
Glassfish wants to establish a connection pool on behalf of my deployed web application.
I want to access a remote database, not one deployed to localhost.
I'm not sure if this works, but in my homespace I put _p14 which now allows to set the URL used for the connection, based on getURL and setURL. It seems you know more on how it works than I do, so if you think you can set it up with this, please try.
participants (3)
-
Fabian Groffen
-
jsolderitsch
-
Martin Kersten