java.sql.SQLException: No data read- jdbcTemplete - database

Trying to run the query using jdbcTemplete on oracle database where M_DB is the schema name and M_USER_DB is user for M_DB schema. M_USER_DB has certain tables on which I am trying to execute some queries like in springboot project
jdbcTemplate.query("SELECT * FROM M_USER_DB.C_USER_INFO", new ResultSetExtractor<HashMap<String, String>>()
However, while running the program its throwing below error:
No data read; nested exception is java.sql.SQLException: No data read
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:104)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
In the application.properties the database/datasource connection are for my primary Schema M_DB (not user M_USER_DB ). From SqlDeveloper, I can connect to M_DB and run the query like
select * from M_USER_DB.C_USER_INFO
without connecting to M_USER_INFO. I believe I need not to create primary and secondary jdbcTemplete here.
Any suggestion what could be the reason or anything I am missing? Thanks for help in advance.

Related

Debezium SQL Server Connector - "Couldn't obtain database name"

I'm trying to set up a Debezium SQL Server Connector against a SQL Server instance that is controlled by DBAs at my workplace. I've been able to start up Zookeeper and Kafka Server without issue, and Kafka Connect itself works with sample Connectors, but when attempting to start a Debezium SQL Server Connector instance I've been getting the error "Couldn't obtain database name".
[2022-07-12 16:36:04,269] ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:117)
java.util.concurrent.ExecutionException: org.apache.kafka.connect.runtime.rest.errors.BadRequestException: Connector configuration is invalid and contains the following 1 error(s):
Unable to connect. Check this and other connection properties. Error: Couldn't obtain database name
Here is my debezium config:
name=Dbz-SqlServer-connector
connector.class=io.debezium.connector.sqlserver.SqlServerConnector
database.hostname=MyDbHost
database.port=1433
database.user=MyUsername
database.password=MyPassword
database.dbname=MyDatabase
database.server.name=MyDbHost
table.include.list=dbo.CdcTest
database.history.kafka.bootstrap.servers=localhost:9092
database.history.kafka.topic=dbhistory.CdcTest
I've tried this in a .properties file passed to a standalone Connect instance, and as a JSON POST to a distributed Connect instance. I have tried all of the same steps on both my local Windows machine as well as on a linux VM, with the same results.
Confluent and Docker are not options for me in this situation.
for SQL Server login credentials, I am using a local account on the SQL Server instance that does have access to the database in question. I found the source code for debezium's connectors on their github and was able to find that specific error message within the code:
private static final String GET_DATABASE_NAME = "SELECT name FROM sys.databases WHERE name = ?";
...
public String retrieveRealDatabaseName(String databaseName) {
try {
return prepareQueryAndMap(GET_DATABASE_NAME,
ps -> ps.setString(1, databaseName),
singleResultMapper(rs -> rs.getString(1), "Could not retrieve exactly one database name"));
}
catch (SQLException e) {
throw new RuntimeException("Couldn't obtain database name", e);
}
}
I'm not completely familiar with Java but it appears that basically something is going wrong when the connector is trying to run "SELECT name FROM sys.databases WHERE name = 'MyDatabase'". When I run this against the database myself, logged in with the same account I'm using, it seems to work just fine, so I'm really not sure where to go from here. It is fair to say that since I'm not in full control of the SQL Server environment that I'm using, there may be some permissions issues that I'm not aware of, but from what I'm able to test it seems like it should be working.
I would greatly appreciate any help at all, whether just suggestions on settings/configs to check or a full-blown solution.
Thank you!
Update: I've built a simple console app to run that sys.databases query against MyDbHost, master database, as the relevant account, and it's working just fine so I feel like that confirms that my connection info is correct and account permissions are also correct. Seems like this is an issue within the Debezium connector.
It turned out that my problem was a mistake in the connector's config setting. I misunderstood which specific pieces of data to put into database.hostname and database.server.name, and one I corrected those fields the connector works.

Schema error when running update-database command to create identity tables for npgsql data provider

I am manually creating the identity tables for a new ASP.NET 6 project following this tutorial. Such tutorial is for MS SQL Server and I am using PostgreSQL so I made the appropriate modifications. Although the process is straightforward, I have a problem when reaching the update-database step where I get the following error: "Couldn´t set schema (Parameter ´schema')". My connection string is as follows: "host=localhost; database=testdb001; schema=testdb001; port=5433; user id=some-user; password=some-password;". I found that such error disappears and the identity tables are successfully created if I remove the schema parameter in the connection string but tables are created in the public schema that PostgreSQL automatically includes when a new DB is created. However, I do not want this to happen because I want to use another schema name. I visited connection strings website for PostgreSQL (https://www.connectionstrings.com/postgresql/) and I see a link for Npgsql, and all the examples here do not contain the schema parameter. This is the first time that I use npgsql. Is there a way to create the identity tables in a specific schema name?
Maybe a workaround is to specify a schema name in the search_path parameter in postgresql.conf file but this would lead to add a name every time I define a new schema. I think that the schema name in the connection string is a great choice but I wonder why this is not accepted for npgsql.
Respectfully,
Jorge Maldonado
I found the solution.
For npgsql you must use search path as a connection string parameter instead of schema. So a connection string is as follows
"host=localhost; database=testdb001; search path=testdb001; port=5433; user id=some-user; password=some-password;"
and not
"host=localhost; database=testdb001; schema=testdb001; port=5433; user id=some-user; password=some-password;"
Regards,
Jorge Maldonado

Setting up Azure SQL data sync's sync group

I just tried setting up Azure SQL data sync's sync group using sample Azure SQL database. I am syncing dbo.BuildVersion table of the sample database.
I get the following error on member database.
Database provisioning failed with the exception "Incorrect syntax near the keyword 'NOT'.Inner exception: SqlException ID: 39f49622-6a56-4a44-8e55-2a646f99a584, Error Code: -2146232060 - SqlError Number:156, Message: SQL error with code 156 For more information, provide tracing ID ‘679953bc-7dac-4490-89e9-ea6d145d0442’ to customer support."
How should I resolve this issue?
Thanks
I am able to resolve this issue by creating empty table in the member database first and then running the sync.
Does Sync service not create table when table does not exist in the member database?
It does create it, however, under certain circumstances it fails to create it do to some issue with the schema itself. Therefore, the workaround, as you figured out, is to create the table manually.

SQL Server User-Defined Table Type / Crystal Reports Error

I was forwarded a Crystal Reports error message that said:
Failed to retrieve data from the database. ... Description: The EXECUTE permission was denied on the object 'xxxx_IDList', database 'DBName', schema 'dbo'.
There is an 'object?' named 'xxxx.IDList' under User-Defined Table Types - in the database.
I have never created or used a User-defined Table Type so I am just trying to figure out how to approach this error and how I might proceed with troubleshooting it.
I am hoping this is not an uncommon error.
Can anyone suggest an approach to solving this problem?
Thanks in advance!
In SQL server, any table that is not a system table is a user-defined table. So, anything in a typical non-system database that holds business data. The error message tells me that you have a database (dbname) on the server you are connecting to. In that database there is at least one schema (dbo, which is the default) and that the table xxxx_IDList lives in that schema.
Your app is trying to execute this table as if it was a function or stored procedure and you do not have permission to do that.
Do you have the source for the app that we can look at?

Error while creating database on OrientDB

When I use the following command to create a database in OrientDB 2.0.10,
CREATE DATABASE plocal:../databases/pincode admin admin plocal
I get the following error.
Creating database [plocal:../databases/pincode] using the storage type [plocal]...
Error: com.orientechnologies.orient.core.exception.ODatabaseException: Cannot create database 'pincode'
Error: com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException:Cannot find a command executor for the command request: sql.select count(*) from ORole where name.type() not in ["STRING"] and name is not null
I get the same error if i try to create the database this way,
CREATE DATABASE remote:localhost/pincode root password plocal
I have connected to the remote server in both cases.
Similar error of command executor not found, pops up even when I try to connect to the database.
Can someone help tell me where I'm going wrong?

Resources