does postgresql jdbc driver has \copy? - java

as stated,
does java jdbc driver for postgresql has client side \copy?
I wanted to do batch inserts into a table in the database on a remote machine with data from my text file on another machine.

Since the 8.4 driver there is support for the COPY command, through the CopyManager:
http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/copy/CopyManager.html

add ip of your system from where you used to update database in pg_hba.conf file
connect usinyg url
jdbc:postgresql://host:port/database
execute query

Related

Cannot connect to database through Intellij's Data Sources and Drivers

I have a problem with displaying my databse structure through Intellij's Data Sources and Drivers page. I can connect to my database which is hosted on a redhat server through using application.properties of my spring project:
spring.datasource.url=jdbc:postgresql://192.168.0.38:5432/cms_database
which works fine. Although, whenever I try to use Intellij's Data Sources and Drivers page I get an Error Message:
[3D000] FATAL: database "cms_database" does not exist.
I can test to connect to database "postgres" which returns a Connection:
DBMS: PostgreSQL (ver. 13.0) Case sensitivity: plain=lower,
delimited=exact Driver: PostgreSQL JDBC Driver (ver. 42.2.5, JDBC4.2)
Ping: 16 ms SSL: no
Any help would be appreciated. If you need any extra info I would be happy to post!
Try to connect with settings from this example
I think you will set hostname wrongly

Oracle DB connection issue

When I try to connect java application to oracle db using jdbc thin client, my system name was sent to db server without host name (eg. 102XXXXX) But when I try with oracle client(PL/SQL developer), my system name was sent to db server with domain name appended (eg. North_America/102XXXXX). And in oracle server, my machine is whitelisted with domain name (eg. North_America/102XXXXX). So I got account locked exception when try to run the java application but have successful connection from PL/SQL developer. I am not sure how to solve this issue from my side. I need both connection. Anyone has any idea?
Note that you can also customize what the Oracle JDBC thin driver sends for the system name during authentication by setting this property "v$session.machine".

How to export MySQL workbench database for Java application runs in other computers?

I developed a Java application connecting to MySQL database through a localhost connection.
Class.forName("com.mysql.jdbc.Driver");
Connection conexao = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/bd_sensores", "root", "rootadmin");
I want to run the application on other computers. To do that I need to export the database, and the information already recorded. I think I need to create an installer and install it on other computers, but I need to change local and type of database.
You could have a properties file that has the following properties:
driver class name
Database Host
Database Port
as well as username.
Read the db configurations from this properties file and then load the driver and prepare your jdbc url.
Also, you can export your database through mysql workbench to a .sql file that will create a db script to run on another database. Use 'Manage Export / Import' functionality of workbench under 'Server Administration'

How to access a hsqldb DB with JDBC tools?

I have a hsqldb file database.
Therefore a folder contains:
hsqldb.script
hsqldb.properties
hsqldb.log
hsqldb.lck
hsqldb.tmp
When I open the script, I can see that SQL tables and INSERTs are present.
How can I use JDBC tools like squirrel to inspect the tables like a real database?
I tried connecting using jdbc:hsqldb:file:C:\path\to\my\data\hsqldb while the application is running that uses this DB.
I could connect, but all I could see are the initial INFORMATION_SCHEMA tables.
What am I missing here? Where is the data that I can see clearly in the .script, but not with an JDBC tool?
The .lck and .tmp files indicate that the database was not shutdown prior to last connection close. Use the SHUTDOWN command to close the database.

How to get all the tables which I created using hsqldb runserver in standlone mode

I created the jdbc connection successfully for hsqldb in stanlone mode.I found where the new database is created.Using the path of newly created database in runserver ,I created some tables.But when I tried to get those table using jdbc connection,I could not get those table.
connection url is:"jdbc:hsqldb:file:databasename;ifexist=true","SA",""
for getting tables I m using the following query.
"select table_name from information_schema.system_tables where table_type='table'";
I am using hsqldb 2.2.7.
You seem to be trying to access the database simultaneously via Server and in-process. This is not possible. After each type of access, you need to shutdown the database before you connect to it via the alternative type of access. Therefore shutdown the Server once you have created the tables, then connect to the database in-process.
It is easier to access the database via Server only, and avoid such problems. Please also upgrade to version 2.2.8 to avoid a bug which may affect a database that has not been shutdown properly.

Categories

Resources