Error while trying to add geometry types to my postgis connection - postgresql

I have create a project with eclipse and added the postgis-jdbc-2.1.7.jar , postgresql-9.4.1208.jre6.jar to my class path.
Then I tried the example from the postgis documentation see example in order to connect to the db.
The following lines produce an error:
/*
* Add the geometry types to the connection. Note that you
* must cast the connection to the pgsql-specific connection
* implementation before calling the addDataType() method.
*/
((org.postgresql.PGConnection)conn).addDataType("geometry",Class.forName("org.postgis.PGgeometry"));
((org.postgresql.PGConnection)conn).addDataType("box3d",Class.forName("org.postgis.PGbox3d"));
The error is the following:
The method addDataType in the type connection is not applicable for the arguments
Has anyone else faced the same error?
Any ideas?

Is this a run-time error? Perhaps Class.forName() is returning null. Try making a static reference to the class by replacing the call to "Class.forName()" with "org.postgis.PGgeometry.class" which will fail at compile time instead of run time if your classpath is off.

Related

Save entity with java.time.Instant property using NamedParameterJdbcTemplate with postgres driver

I am having issues saving my entity that has a Instant value using the NamedJdbcTemplate. I receive the exception listed below and I am trying to determine the best way to resolve this. Please advise.
Can't infer the SQL type to use for an instance of java.time.Instant. Use setObject() with an explicit Types value to specify the type to use.
I am using the postgresql:9.4.1212 driver
This code worked for me:
Instant ts = // whatever instant
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("ts", Timestamp.from(ts), Types.TIMESTAMP);
jdbcTemplate.queryForList(SQL, params)
where SQL is the parametrized query and make sure you're using java.sql.Timestamp and java.sql.Types.

Profiling DB2 connection with MiniProfier

I'm trying to add MiniProfiler to my DB2 connections. Below is my simplified code.
public void InitializeConnection()
{
DB2Connection cnn = new DB2Connection("connection String");
var profiler =
new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current);
IDbCommand c = new DB2Command();
c.Connection = profiler ;
}
My problem is occurring in the last line where the profiler is assigned to the DB2Command's Connection property. I'm getting the below error.
Unable to cast object of type 'StackExchange.Profiling.Data.ProfiledDbConnection' to type 'IBM.Data.DB2.DB2Connection'
I've tried a couple of different casting ideas and nothing has worked out.
I think you're going at it backwards. You're assigning the connection to the ProfiledDbConnection class (as seems to be correct, based on the docs on the MiniProfiler website).
However, you're then creating a DB2-specific command object, and trying to assign the ProfiledDbConnection class to the connection object.
I think what you want to do is call profiler.CreateDbCommand(), which will create a ProfiledDbCommand object that uses the DB2Command class "under the covers".
The DB2Command.Connection property is of the type DB2Connection (as the error message helpfully tells you). Try DbConnection instead:
c.DbConnection = profiler
More in the manual

GWT: JsArray and JavaScript object

Am facing an issue while trying to implement an example given over a website.
One of the methods in a class has a signature like this -
private void updateTable(JsArray prices) {....}
And am trying to invoke this method from another method as -
updateTable(JsonUtils.safeEval(response.getText()));
while doing this am seeing a compilation error as -
The method updateTable(JsArray) in the type StockWatcher is not applicable for the arguments (JavaScriptObject)
Though I have just used the exact code displayed in the website, am seeing this error. Not sure what needs to be done. Please help.
The problem has been fixed by making the following change -
updateTable((JsArray)JsonUtils.safeEval(response.getText()));
introduced a casting in the above statement.

Glimpse ADO fails in Web Site project with TableAdapters - Part 2

This is a follow up to this problem.
That problem was fixed. However, new compiler errors occurred. The compiler errors indicate the following:
The Glimpse.Ado.AlternateType.GlimpseDbCommand class needs a default constructor
The Glimpse.Ado.AlternateType.GlimpseDbConnection class needs a constructor that takes a string (connectionString)
This second problem is strange, because the System.Common.DbConnection class does not have a constructor that takes a string either.

Getting error while deploying code to production-->Previous load of class failed: qbdialer|insidesalessetup

I am facing an error conflict while deploying any code to the production.
Error is:
Previous load of class failed: qbdialer|insidesalessetup
qbDialer is a managed package.
Can anybody please help me to overcome from this issue?
Is your insidesalessetup class trying to call a method somewhere within qbdialers package? These errors tend to indicate you have a pre-existing class which has a reference to a method or class that no longer exists.
For example, if I created a class with a method Add(integer x, integer y, integer z), wrote a test method that called Add(1,2,3), then saved these they would both save okay. If I altered the method to just be Add(integer x, integer y) - removing the z parameter - I would get the error you are on about when I next ran my tests.
Paul