History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SQL-27
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Bob Swift
Reporter: Quent Chalmers
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Confluence SQL Plugin

setReadOnly method is not implemented error

Created: 27/Oct/07 02:28 PM   Updated: 26/Apr/08 12:16 AM
Component/s: SQL macro
Affects Version/s: 3.3.0
Fix Version/s: 3.4.0

Time Tracking:
Not Specified

Environment: Confluence Version: 2.6.0 Build:#913 Sep 27, 2007 on Tomcat 5.0.25 + beta_fix SQL macro 3.3.1b1

Labels:


 Description  « Hide
I'm having a problem with a proprietary JDBC driver to a middle tier server. The datasource that I have defined seems to work OK from a beanshell query but not from the sql or sql-query macros. The following is the result from sql-query, sql, and beanshell run:

sql-query: java.sql.SQLException: The method Connection.setReadOnly is not implemented yet
select Fld1, Fld2 FROM Table WHERE Fld1 like '608174%'

sql: java.sql.SQLException: The method Connection.setReadOnly is not implemented yet
select Fld1, Fld2 FROM Table WHERE Fld1 like '608174%'

Isolation set: 0
Columns in result set: 2
6081740 EA2
The following is the code (beanshell code is modified copy from the scripts plugin page):

{sql-query:dataSource=PhsDev|output=wiki|showsql=true}
select Fld1, Fld2 FROM Table WHERE Fld1 like '608174%'{sql-query} {sql:dataSource=PhsDev|output=wiki|showsql=true|transactionIsolation=none}
select Fld1, Fld2 FROM Table WHERE Fld1 like '608174%'{sql} {beanshell}

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.NameNotFoundException;

String dataSource = "PhsDev";
String sql = "select Fld1, Fld2 FROM Table WHERE Fld1 like '608174%'";


DataSource ds = null;
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet;

try {
ds = (DataSource) (new InitialContext()).lookup("java:comp/env/jdbc/" + dataSource);
connection = ds.getConnection();
int isolation = connection.getTransactionIsolation();
out.println("<br>Isolation set: " + isolation);

statement = connection.prepareStatement(sql);

if (statement.execute()) { // result set is available
resultSet = statement.getResultSet();
if (resultSet != null) {
ResultSetMetaData rsmd = resultSet.getMetaData();
out.println("<br>Columns in result set: " + rsmd.getColumnCount());

// out.println("<br>Space names: ");
while (resultSet.next()) { out.println("<br>  " + resultSet.getString("Fld1") + "  " + resultSet.getString("Fld2")); //"spacename")); }
}
} else { // only update count available out.println("Update count: " + statement.getUpdateCount()); }
}
catch (NameNotFoundException exception) { out.println(exception.toString()); }
catch (NamingException exception) { out.println(exception.toString()); }
catch (SQLException exception) { out.println(exception.toString()); } }
finally {
try {
if (resultSet != null) { resultSet.close(); }
if (connection != null) { connection.close(); }
}
catch(Exception discard) {
}
}{beanshell}

The following is the datasource definition:

<Resource name="jdbc/PhsDev" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/PhsDev">
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
<parameter><name>driverClassName</name><value>com.phs.client.jdbc.PhsJDBCDriver</value></parameter>
<parameter>
<name>url</name>
<value>jdbc:scwapi://host/NameServer;uid;pswd;db;schema;uid2;pswd2</value>
</parameter>
<parameter><name>maxActive</name><value>20</value></parameter>
<parameter><name>maxIdle</name><value>10</value></parameter>
<parameter><name>maxWait</name><value>-1</value></parameter>
<parameter><name>removeAbandoned</name><value>true</value></parameter>
<parameter><name>removeAbandonedTimeout</name><value>600</value> </parameter>
<parameter><name>logAbandoned</name><value>true</value> </parameter>
</ResourceParams>

Versions used: Confluence Version: 2.6.0 Build:#913 Sep 27, 2007 on Tomcat 5.0.25

Also tried the transactionIsolation switches without success. Any ideas would be appreciated.



 All   Comments   Work Log   Change History   FishEye   Crucible   Related Builds      Sort Order: Ascending order - Click to sort in descending order
Bob Swift - 27/Oct/07 11:51 PM
Thanks for creating the issue. Loop problem may be result of the support in the SQL macro for multiple results sets and use of the following statements that might not be correct for your driver:
... loop on results ...
result = statement.getMoreResults();
if (result) {   // result set returned
     resultSet = statement.getResultSet();
 ...
} else {	    // no result set, must get update count instead
   statement.getUpdateCount()
...
}

getUpdateCount is suppose to return -1 if there are no more results sets or no update count is available

To avoid this, I have added temporary parameter - set multipleResults = false and see how that does with the following driver: beta-fix2


Quent Chalmers - 28/Oct/07 04:53 PM
Bob,
Thanks, that fixed it for this quick test.

Here are the log entries from the run:

Oct 28, 2007 4:29:08 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 36885 ms
2007-10-28 16:30:14,828 DEBUG [http-8080-Processor25] [swift.confluence.sql.SqlMacro] convertTransactionIsolation Transaction isolation requested: TRANSACTION_READ_COMMITTED
2007-10-28 16:30:14,828 DEBUG [http-8080-Processor25] [swift.confluence.sql.SqlMacro] convertTransactionIsolation Transaction isolation requested: TRANSACTION_READ_COMMITTED
AbandonedObjectPool is used (org.apache.commons.dbcp.AbandonedObjectPool@1a1446d)
LogAbandoned: true
RemoveAbandoned: true
RemoveAbandonedTimeout: 600
Connecting to //host/NameServer
Connected to //host/NameServer (Phs 20.0)
Connecting to //host/NameServer
Connected to //host/NameServer (Phs 20.0)
2007-10-28 16:30:30,527 DEBUG [http-8080-Processor25] [swift.confluence.sql.SqlMacro] execute java.sql.SQLException: The method Connection.setTransactionIsolation(int) is not implemented yet
2007-10-28 16:30:30,527 DEBUG [http-8080-Processor25] [swift.confluence.sql.SqlMacro] execute java.sql.SQLException: The method Connection.setTransactionIsolation(int) is not implemented yet
2007-10-28 16:34:30,748 DEBUG [http-8080-Processor24] [swift.confluence.sql.SqlMacro] convertTransactionIsolation Transaction isolation requested: TRANSACTION_READ_COMMITTED
2007-10-28 16:34:30,748 DEBUG [http-8080-Processor24] [swift.confluence.sql.SqlMacro] convertTransactionIsolation Transaction isolation requested: TRANSACTION_READ_COMMITTED
2007-10-28 16:34:34,306 DEBUG [http-8080-Processor24] [swift.confluence.sql.SqlMacro] execute java.sql.SQLException: The method Connection.setTransactionIsolation(int) is not implemented yet
2007-10-28 16:34:34,306 DEBUG [http-8080-Processor24] [swift.confluence.sql.SqlMacro] execute java.sql.SQLException: The method Connection.setTransactionIsolation(int) is not implemented yet


Bob Swift - 28/Oct/07 10:09 PM
Good, use the beta until I integrate this into an official release which is unlikely before end of Nov with my current work schedule .

Bob Swift - 26/Apr/08 12:16 AM
This is now officially released.