SQLCODE=-104, SQLSTATE=42601, DRIVER=4.7.85 - eclipse

Any idea of how to connect to db2 in an sql file in an Eclipse application?
I spent hours on trying to connect db2 using the following statement without any luck
[CONNECT'jdbc:db2://localhost:50000/DB2ADMIN;create=true;user=db2admin;password=db2admin']
What I'm typing wrong?
I can ping the db and I can create tables but can not connect to it into my application
please help....

Are you sure about your connection string:
Server: localhost
Instance number: 50000
Database name: db2admin
Username: db2admin
Password: db2admin
It is weird to have a database called db2admin.
What is the purpose of the 'create' option in the URL. I did not found that in the documentaion.
For more information about how to define the URL, please take a look at this page: http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_rjvdsprp.html

Related

postgresql pg library taking windows username instead of postgresql

i am using pg lib in strapi application, where initially it creates postgres connection using correct postgresql username(postgres), database name(strapi_db) and password(postgres) but after login it changed it to connect using my windows 10 username(rayappan.a, and database as rayappan.a). it seems strange to me because i never configured anywhere to use my windows credentials for POSTGRESQL connection. please any one tell me how to fix username connection issue
Regards,
Rayappan Antoniraj
Take a look into https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING . It states that username:
Defaults to be the same as the operating system name of the user running the application."
The database name:
Defaults to be the same as the user name.
So it seems a new connection with parameters not set is made.

Not able to make postgres database call on heroku using Play Framework Application

I am build REST api using play framework 2.8 , I am able to start the application and call some service. Facing issue when trying to connecting with postgres database. Logs are below -
Error opening connection for database: {}org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "3.87.112.32", user "abc", database "xyz", SSL off
Tried looking solution for this and foudn have to add sslmode=require in query param while connection to database.
When log the url sslmode is already mentioned.
jdbc:postgresql://abc.amazonaws.com:5432/xyz?password=1234&sslmode=require&user=xyz
I am reading this property from heroku env variable JDBC_DATABASE_URL for obtaining database connection.
This issue can be fixed by adding addition query parameters apart from sslmode=require which are ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory after adding this the new URL become jdbc:postgresql://abc.amazonaws.com:5432/xyz?password=1234&sslmode=require&user=xyzssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

Cannot connect to https://api.elephantsql.com from pg admin

has anyone success to create connection to elephantsql.org using pgadmin?
i want to try to store my database on a server and im trying to use elephantsqlcom
i want to connect to it using pg admin to make maintenance easier. i have followed this instruction : https://www.elephantsql.com/docs/pgadmin.html but keep getting this error
what should i do? thanks all
change database name from postgres to xwpgagbb similar to:
see user AND DEFAULT DATABASE are the same?..

PostgreSQL: One database to multiple user

I have PostgreSQL 9.3 version. I have created database name db1 now I need it to share with other users who all are connected with the LAN's to connect other applications with the same database.
In SQL Server: We can do this by selecting server name with login details.
Question:
Is it possible in PostgreSQL?
If yes, how can do this?
What is the procedure?
You will need to modify pg_hba.conf to allow remote connections to the database. Information about pg_hba.conf can be found here.
After that, you can connect programatically with a connection string, or similar to your image, with a GUI application like pgAdmin.
To connect (remotely or locally) from pgAdmin choose File -> Add Server... and enter the connection information into the dialog box. Here's an example of the window:
Your client computers will also need to have PostgreSQL drivers as well. If you're doing this in Windows, you'll probably be using ODBC. The PostgreSQL ODBC drivers are here. Info on the connection string format can be found here.
Here's an example of what pgAdmin looks like:

Error connecting to the Server in postgreSQL

I am trying to add a connection to the server in postgreSQL. But when I fill all the details I get this error
Error connecting to the server: FATAL: role "abc" does not exist.
"abc" is the username I want to create.
I am using Tomcat server eclipse for this.
Please help me find a solution to this problem.
Thanks in advance!
If the user does not yet exist, you will have to login as the admin and create it before you can login as that user.