encoding error accessing postgresql from wildfly - postgresql

just setting up new computer and I can't get my wildfly to connect to the postgres. I'm using same standalone.xml as on old computer.
The postgres database is configured to UTF8 (default). Usign pgadmin, I restored from backup and it shows german Umlaute correctly.
But when I start wildfly, I get following error:
Caused by: java.io.IOException: Ung³ltige UTF-8-Sequenz: das erste Byte ist 10xxxxxx: 187
at org.postgresql.core.UTF8Encoding.decode(UTF8Encoding.java:104)
at org.postgresql.core.PGStream.ReceiveString(PGStream.java:331)
at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:705)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
... 35 more
sorry for the german error message. I have no idea why this message is in german.
any ideas what could be wrong?

it turned out that there is an issue with parsing error messages coming with a different locale. Apparently the postgresql jdbc driver can only handle english error messages and there was an error.
Root cause: I made a spelling mistake for a table in the database. That caused Postgresql to throw an error. But it threw the error with a german error message. And the postgresql jdbc driver was unable to parse it and threw a new error as shown in the question.
I fixed the original spelling error and with the root cause gone, there was no more error message to parse.
a year later (now) I finally fixed the locale issue by editing the standalone.xml:
<datasource jndi-name="java:jboss/datasources/PostgresDS" ...>
...
<new-connection-sql>SET lc_messages TO 'en_US.UTF-8'</new-connection-sql>
...
</datasource>

Related

Database connection failed when reading from copy

I am using kafka source connector for capturing CDC from RDS Aurora Postgres. Getting this error.
Please assist if someone know this issue.
Caused by: org.postgresql.util.PSQLException: Database connection failed when reading from copy
at org.postgresql.core.v3.QueryExecutorImpl.readFromCopy(QueryExecutorImpl.java:1074)
at org.postgresql.core.v3.CopyDualImpl.readFromCopy(CopyDualImpl.java:37)
at org.postgresql.core.v3.replication.V3PGReplicationStream.receiveNextData(V3PGReplicationStream.java:158)
at org.postgresql.core.v3.replication.V3PGReplicationStream.readInternal(V3PGReplicationStream.java:123)
at org.postgresql.core.v3.replication.V3PGReplicationStream.readPending(V3PGReplicationStream.java:80)
at io.debezium.connector.postgresql.connection.PostgresReplicationConnection$1.readPending(PostgresReplicationConnection.java:397)
at io.debezium.connector.postgresql.PostgresStreamingChangeEventSource.execute(PostgresStreamingChangeEventSource.java:119)
at io.debezium.pipeline.ChangeEventSourceCoordinator.lambda$start$0(ChangeEventSourceCoordinator.java:99)
... 5 more
Caused by: java.net.SocketException: Socket is closed
at java.base/java.net.Socket.setSoTimeout(Socket.java:1155)
at java.base/sun.security.ssl.BaseSSLSocketImpl.setSoTimeout(BaseSSLSocketImpl.java:639)
at java.base/sun.security.ssl.SSLSocketImpl.setSoTimeout(SSLSocketImpl.java:73)
at org.postgresql.core.PGStream.setNetworkTimeout(PGStream.java:589)
at org.postgresql.core.PGStream.hasMessagePending(PGStream.java:139)
at org.postgresql.core.v3.QueryExecutorImpl.processCopyResults(QueryExecutorImpl.java:1109)
at org.postgresql.core.v3.QueryExecutorImpl.readFromCopy(QueryExecutorImpl.java:1072)
... 12 more
Debezium 1.1.0.CR1 already handles auto-reconnects in these cases https://debezium.io/blog/2020/03/13/debezium-1-1-c1-released/
yes Jiri Pechanec. Actually the problem was with debezium version. older version does not support Postgres auto-connect facility if connection lost for some temporary issue. Now new version of debezium (1.1.0) support auto-connect facility.

Create db2 dataSource in WAS liberty profile

I am developing for Websphere 8.5 (for z/OS), but i would like to use Liberty for local development on my Windows machine. I can't get the data source to work.
I created the following entry in the Server.xml to define the data source.
<library id="DB2JCC2Lib">
<fileset dir="C:\Program Files\IBM\SQLLIB\java"/><!--includes="db2jcc.jar db2jcc_license_cu.jar db2jcc_license_cisuz.jar"-->
</library>
<dataSource id="xxdb" jndiName="jdbc/xxxx" type="javax.sql.ConnectionPoolDataSource">
<jdbcDriver libraryRef="DB2JCC2Lib" id="db2-driver" javax.sql.ConnectionPoolDataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"/>
<properties.db2.jcc driverType="2" databaseName="xxxx" portNumber="50000" user="xxxx" password="{aes}xxxx"/>
</dataSource>
When my application initializes i get the following error message:
[jcc][4038][12241][3.61.65] T2LUW exception: SQL30081N Kommunikationsfehler. Verwendetes Kommunikationsprotokoll: "TCP/IP". Verwendete Kommunikations-API: "SOCKETS". Position, an der der Fehler erkannt wurde: "127.0.0.1". Übertragungsfunktion, die den Fehler festgestellt hat: "connect". Protokollspezifische(r) Fehlercode(s): "10061", "", "". SQLSTATE=08001
I think this message comes from the db2 Driver, unfortunately i didn't find a way yet to change it to english; but i think it's understandable for english speakers.
I have an ODBC System datasource that connects to DB2 v10 maintenance level 015 for z/OS. My local DB2 Connect Installation is v9.7.300.3885.
In my regular Websphere my working datasource has driver type 2, database Name set to the odbc-name and port number 50000. Server name is not set (empty). Classpath and implementation class is the same that i provided in the server.xml
I have tried everything i could find, any ideas?
Note: I can't make changes on the db2 server and there is no issue connecting to the database with other tools and the regular WebSphere.
Also the server name in the websphere configuration is empty, only database name is set. When i tried to set the servername in the server.xml to localhost or the db2 server i got the same result.
Any help is appreciated!
Edit: updated with correct Version Information
Edit 2: As long as it works i dont care what type (2 or 4) of the jdbc driver is used. I just want to point out again that type 2 is currently working on my machine. I tried it with type 4 and got the following message:
[jcc][t4][2043][11550][3.61.65] Exception java.net.ConnectException: Error opening socket to server xxx/xxx.30.3.34 on port 50,000 with message: Connection refused: connect. ERRORCODE=-4499, SQLSTATE=08001 DSRA0010E: SQL State = 08001, Error Code = -4,499
Sorry, previous post ate my xml. Trying again:
You will need a type 4 datasource to connect to a remote database server, i.e.,
<dataSource id="xxdb" jndiName="jdbc/xxxx" type="javax.sql.XADataSource">
<properties.db2.jcc driverType="4" serverName="the.db2.host.com" portNumber="50000" user="xxxx" password="xxxx" databaseName="LOC1" currentSQLID="SYSA"/>
<jdbcDriver libraryRef="DB2JCC2Lib">
</dataSource>
Type 2 is only for a local z/OS connection to a database resource. Your Windows, being remote from z/OS, requires you to use a type 4 connection. Type 4 requires both the serverName and portNumber to be specified. These are not applicable on a type 2 connection.

iReport designer 4.5.1 /4.6.0 cannot interact with Hive

I have followed the instructions from here and installed the updated plugin. The error has become:
Query error
Message: net.sf.jasperreports.engine.JRException:
Error executing SQL statement for : null Level: SEVERE Stack Trace:
Error executing SQL statement for : null com.jaspersoft.hadoop.hive.HiveFieldsProvider.getFields(HiveFieldsProvider.java:113)
com.jaspersoft.ireport.hadoop.hive.designer.HiveFieldsProvider.getFields(HiveFieldsProvider.java:32)
com.jaspersoft.ireport.hadoop.hive.connection.HiveConnection.readFields(HiveConnection.java:154)
com.jaspersoft.ireport.designer.wizards.ConnectionSelectionWizardPanel.validate(ConnectionSelectionWizardPanel.java:146)
org.openide.WizardDescriptor$7.run(WizardDescriptor.java:1357)
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
After downgrading to 4.5.0 the error has become (the connection is verified and I am able to query the table from hive):
Query error
Message: net.sf.jasperreports.engine.JRException: Query returned non-zero code: 10, cause:
FAILED: Error in semantic analysis: Line 1:14 Table not found 'panstats' Level:
SEVERE Stack Trace: Query returned non-zero code: 10, cause:
FAILED: Error in semantic analysis: Line 1:14 Table not found 'panstats'
com.jaspersoft.hadoop.hive.HiveFieldsProvider.getFields(HiveFieldsProvider.java:260)
com.jaspersoft.ireport.hadoop.hive.designer.HiveFieldsProvider.getFields(HiveFieldsProvider.java:32)
com.jaspersoft.ireport.hadoop.hive.connection.HiveConnection.readFields(HiveConnection.java:146)
com.jaspersoft.ireport.designer.wizards.ConnectionSelectionWizardPanel.validate(ConnectionSelectionWizardPanel.java:146)
org.openide.WizardDescriptor$7.run(WizardDescriptor.java:1357)
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
I am using Hive 0.8.1 on OS X Lion 10.7.4.
Is your query as simple as select * from panstats? I suspect that the query is not the problem, but you'll want to confirm that first.
You could try querying that table from a tool like SQuirreL SQL. If that tool also cannot get the data, then it's probably a Hive issue. If it can... then it's probably an issue with iReport or the Hive plugin.
It sounds like Hive is not configured to share metadata. It uses the annoying default configuration with Derby, so outside connections don't get access to your panstats table. I came across this article about configuring Hive earlier this year. It documents using MySQL instead of derby. If that's indeed the problem, then it's just a Hive configuration issue. Following that article would solve things both for SQuirreL and for iReport.

Bad value for type timestamp on production server

I'm working with: seam 2.2.2 + hibernate + richfaces + jboss 5.1 + postgreSQL
I have an module which needs to load some data from the database. Easy. The problem is, on development it works fine, 100%, but when I deploy on my production server and try to get the data, an error rise:
could not read column value from result set: fechahor9_504_; Bad value for type timestamp : [C#122e5cf
SQL Error: 0, SQLState: 22007
Bad value for type timestamp : [C#122e5cf
javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not execute query
[more errors]
Caused by: org.postgresql.util.PSQLException: Bad value for type timestamp : [C#122e5cf
at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:232)
[more errors]
Caused by: java.lang.NumberFormatException: Trailing junk on timestamp: ''
at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:226)
I can't understand why it works on my machine (development) and why not on production. Any clues? Anyone gone through the same problem? Is exactly the same compilation
Stefano Travelli was right. I was checking the jBoss on production and there was an old jdbc driver on [jboss_dir]/common/lib from an old jwebstart application (not developed by me). Deleted that jdbc and it works fine. I should check if the old application is still needed and if so, check if it still works without the jdbc being there or with an upgraded version.
Not sure what the driver story is ..
but the problem for me show up when JDBC tries to parse bigint from the DB to
myOjbect.setDate(Date date){...}
the other "JDBC friendly" is ignorred for some reason .
myOjbect.setDate(long date){...}
So .. removing the Date setter and leaving a long one resolves the problem.
This is a Big workaround .. but may help someone out there :)

How to disable Postgresql messages translation

Is there a way to disable the Postgresql translation of messages? I´m running my appl and Postgresql on a pt_BR Windows machine and when a exception is thrown the error message is translated to Portuguese, like:
Caused by: org.postgresql.util.PSQLException: ERRO: relação "unidade_federacao" não existe
Posição: 25
I would like the messages to appear in English.
I´m using the driver postgresql-8.4-701.jdbc3.jar on a Java (with Hibernate) app.
thanks in advance,
Fabrício Lemos
You could change lc_messages in postgresql.conf or just per database:
ALTER DATABASE dbname SET lc_messages=en_us;
See also the manual.
Under Windows, some psql error messages are getting translated corresponding to the format setting in Windows settings -> Clock, Language, and Region -> Change location -> Formats -> Format.
To prevent a mix of translated and untranslated messages, I've set this format to "English (United States)".
execute the following query to your database in order to find the postgres.conf file which is loaded for the configuration:
SHOW config_file;
Edit your postgres.conf file with your prefered lc.... lc_messages,lc_numeric...etc.
i think you can change all with lc_ALL
example : lc_ALL=en_US.UTF-8
Finally execute the following command to reload conf.
SELECT pg_reload_conf();