Getting schemas from all the available database in snowflake - jdbc

I am trying to get all the schema from a database which I passed in the connection url in snowflake jdbc driver.
Observation :
I am getting all the schema from all the databases even though I pass wrong database.
wrong database/schema/warehouse does not validate during the connection creation time.
URL : jdbc:snowflake://XXXXX.region.aws.snowflakecomputing.com?role=custome_role&warehouse=test_wh&db=test_db&schema=test_schema &CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX=true
Why Snowflake JDBC driver does not validate the wrong warehouse/database/schema during connection creation time or query execution time?

What I see is that there is no check on the DB name parameter being passed in the connection url.
The only check that is done is for Role and if the role is existent then all the db's for that will be listed.

Use
statement.executeQuery("show databases;");
And check if the list contains the requested database

Related

Specifying a database in JDBC URL for Netezza

When connecting to Netezza via JDBC, the database in the URL is a required field - e.g. the value sales in the example URL jdbc:netezza://main:5490/sales;user=admin;password=password
The first time I connect to a Netezza instance, I don't (necessarily) know the name of a database on the appliance. Guessing a database name is a very time consuming exercise.
In this scenario, what value should I provide? Is there a "use default" option, a way to list databases, or a specific database name that will always work (e.g. a system database)?
Netezza will always have one main database: system.
You cannot delete the system database.
I would suggest that you connect to jdbc:netezza://hostname:5480/system.
Once connected, you can list the databases that your user has access to, using
select database
from _v_database;
I can't answer definitively, but it appears that every Netezza appliance by default has a database named TESTDB. This is at least true for all the appliances to which I have access.
Users or administrators may be able to delete this database, but it's a good bet if you need a database to which to connect.

Can't find tables and data of my H2 database

A webapp is using following configuration to store some data in DB:
spring.datasource.continueOnError=true
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:mydb
I was trying to reach this DB using H2 Console, but something is wrong. There are no tables even though I know they were created. I can also access any made up JDBC:URL like jdbc:h2:mem:fakeXYZ just as well with same result. What is goning on here? How can I see this DB tables and data?
Your JDBC URL specifies a named in-memory database which by default only will be available for connections from within the same virtual machine.
You can either change the URL to use a file-based database, or you will have to start a TCP server to allow for connections from other processes.

Hive JDBC fails to connect configured schema

I am able to connect to Hive using hive-jdbc client and also using the beeline.Typical url is,
jdbc:hive2://hive_thrift_ip:10000/custom_schema;principal=hive/hive_thrift_ip#COMPANY.COM
Unfortunately the connection is always established to the 'default' schema of Hive , and it is not considering the configured schema name in the url. I use the org.apache.hive.jdbc.HiveDriver class
It always takes me to the tables of the default schema. Still I am able to access the tables from other schema using the schema name prefix to the tables, like custom_schema.test_table
Kindly let me know if I missed any property or configuration in the connection creation part which will help me in getting the session exclusively for the schema that configure in the url.
Many thanks.

Database url in jmeter?

I have a database stored at a server. I want to load test the server using jmeter.It requires a field called database url? Now what i am supposed to fill in that?
Also it is asking for jdbc driver class? What will be the values of these two?
JMeter uses JDBC.
What is your db ? Oracle, mysql ...
Each Db provides drivers you need to put in jmeter/lib folder.
For url each driver has a syntax, examples:
http://www.petefreitag.com/articles/jdbc_urls/
Then you need to add login/password
your database url should be -jdbc:mysql://localhost:3306/
database url is the host address of the database u can see that when you connect mysql from gui using SQl yog
is the database name that you have created in mysql
Your driver class should be -com.mysql.jdbc.driver
user name and password of the database

Spring Datasource and Database Schema

I am trying to declare a Spring datasource pointing to a DB2 database. Presently I am using a org.springframework.jdbc.datasource.DriverManagerDataSource to setup the connection but am not finding any way to specify the database schema in the database in the datasource bean. Could anyone help me on this?
Problem is there is no standard way to set the schema, each database has a different mechanism.
A work around is to set the schema as part of the db url...
For db2 the url will look something like:
jdbc:db2://SERVER_NAME:PORT/DATABASE:currentSchema=SCHEMA_NAME;
hope that helps...
Special note: make sure you add the semicolon ; at the end of the URL, otherwise you will get errors saying URL is invalid. Also make sure nothing after last ; exists (not even spaces).
There isn't a means to do this with the standard Spring namespace. Rob Harrop's response to a request to add the schema to the configuration:
In general, this kind of functionality should be pushed into the connection pool since there is no really elegant and performant way to do this via a decorator. The pool can set the schema once per connection it creates, whereas here you have to set it each time a connection is retrieved.
If you're desperate to set the proxy in your configuration, the submitter included some code for a proxy to allow the schema to be specified.
If your connection uses the owner of the schema as the user then that connection will point to that particular schema.
ie. If user user1 is the owner of the database schema named schema1 then if you connect to the database using user user1 then by default the connection will point to schema1.
We have used UserCredentialsDataSourceAdapter provided by spring to connect to different schemas based on the logged in user. This provides a datasource which is pointing to a particular schema based on the user. This uses a thread based login information. Each thread has to decide to which schema it has to connect and provide the user according to that.

Resources