How to create/drop a database on DB2 through JDBC? - jdbc

I have some test code using JDBC to connect to MySQL, PostgreSQL, Oracle, and SQL Server, with only some minor differences between databases. I would like to run this test code as well on DB2. To start with a blank slate, and also test our database creation DDL, the tests start by creating a database (e.g. CREATE DATABASE), and end by deleting that database (e.g. DROP DATABASE).
I read a comment from 2012 saying that, at least on DB2 for Linux, one can't run CREATE DATABASE and DROP DATABASE through JDBC, but only from the command line, which would be a bummer for running my integration tests on DB2. Is there really no way of creating, and then dropping a database through JDBC?

JDBC is for only SQL. Create database or Drop database is not SQL, and for this reason that statement cannot be executed from JDBC. You can execute DB2 commands via Runtime class, or using JNI to use the DB2 API
db2 create database command http://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0001941.html
sqlecrea API http://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.apdv.api.doc/doc/r0001446.html

Related

Oracle Privilege - User can create table but cannot write rows

A user has been configured on Oracle. Via this user, I can create an ODBC connection and an OCI connection, and these both test fine in Win10. Using Alteryx with the ODBC and OCI connection, we try to write data to a new table.
The table is created and appears in PL/SQL with the expected column names. However, the rows are never written and the connection just hangs at this point.
What could be wrong? I am not an Oracle Admin
Based on comments you were expecting oracle to commit without executing "commit" command explicitly. It's not enabled by default in oracle so you have to turn it on.
It's not possible to turn this on for the database, but on client apps only.
E.g. "set autocommit on" command in SQL Plus.
So you need to check docs for the client application you're connected with (presumably Alteryx is the one). It might have such a feature.

How to migrate(convert) database(or just tables) from PostgreSQL to Oracle using only Oracle tools?

Data was sent to our company with PostgreSQL, but we are prohibited to use the tools of PostgreSQL , permitted the use of only Oracle.
How to migrate data from PostgreSQL to Oracle without using a third party application(they are also prohibited)? You can only use the tools of Oracle.
I found this article https://support.oracle.com/knowledge/Oracle%20Database%20Products/2220826_1.html but we don't have Support Identifier
We have one .sql file. It weighs 8 Gigabytes.
It looks like you have so many impediments in your company. Regarding Oracle's SQL Developer Migration Workbench, unfortunately it does not support the migration of PostgreSQL databases. However, the following 3rd-party software tools are available and may assist in migration, but I am afraid you cannot use them as you said that those products are forbidden:
http://www.easyfrom.net/download/?gclid=CNPntY36vsQCFUoqjgodHnsA0w#.VRBHKGPVuRQ
http://www.sqlines.com/postgresql-to-oracle
Other options will only move the data from your Postgresql database to Oracle database, it means that you must have the DDLs of the tables before to run the import:
To move data only, you can generate a flat file of the the
PostgreSQL data and use Oracle SQL*Loader.
Another option to migrate data only is to use Oracle Database
Gateway for ODBC which requires an ODBC driver to connect to the
PostreSQL database, and copy each table over the network using
sqlplus "COPY" or "CREATE TABLE AS SELECT" commands via oracle
database link.
Also, Oracle has discussion forum for migrating non-oracle databases to Oracle.
http://www.oracle.com/technetwork/database/migration/third-party-093040.html
But, if you have only a sql file, you should look at it to see whether you have both DDLs ( create tables and indexes, etc ) and the data itself as insert statements. If so, you need to split it and treat the DDLs to convert the original data types to Oracle datatypes.

Need to migrate Oracle transaction data to Azure SQL

There is one scenario where in our target is to migrate oracle database to Azure SQL DB.
Currently I am evaluating multiple options to migrate the existing Oracle Db to the Azure SQL DB, for the same reason I could not decide how to handle this situation where in the source DB i.e. Oracle is having transaction data which is a kind of incremental load.
Should this can be handled with mere replication of DB? or performing some data migration steps would help me ? Here i can think of earlier approach as easier approach where in i need not to worry about the transaction updates happening inside the data.
Considering this which utility i should use to perform this kind of activity?
You can replicate your Oracle database to Azure using Oracle Golden Gate as a way to migrate your Oracle database to Azure SQL. Striim seems to be another good tools to move your database to Azure SQL.
I think you may use the SQL Server Migration Assistant (SSMA) for Oracle.
SQL Server Migration Assistant (SSMA) for Oracle consists of a client application that you use to perform a migration from Oracle to SQL Server and Azure SQL DB. It also contains an extension pack that supports data migration and the use of Oracle system functions in your migrated databases.
SSMA can converts the transaction processing:
For more details, you can see:SQL Server Migration Assistant (SSMA) for Oracle
Hope this helps!

How do I set the SDE version in SSIS dataflow source

I have a GIS oracle database and I am needing to reference in a SSIS dataflow task. Ideally I would normally do something like this (which works perfectly in Oracle SQL Developer):
execute sde.version_util.set_current_version('SAFE.mvedits')
SELECT CAD_EVENTID
FROM SAFE.INCIDENT_POINT_MV
however when I try to use that as the SQL command of my OLE DB Datasource it throws me an "Invalid SQL" error.
How do I set the SDE version in a SSIS dataflow task data source?
Knowing nothing of nothing on Oracle, what you might try is
In your Oracle Connection Manager, change the property RetainSameConnection to True. This means that all connections will Oracle will use the same thread.
Add an Execute SQL Task before your Data Flow that talks to Oracle. Use your query there to modify the current version thing. This setting should be persisted on the connection.
In your OLE DB Datasource, start with the SELECT statement.
You might need to set DelayValidation to true as well.
If that's not working, let me know and I'll see if I can come up with anything else.
As it turns out this is a shortfall of interacting with GIS Oracle databases through thirdparty applications. In my situation we addressed it by just bundling the change up in a stored procedure that lives on the oracle server and invoking that stored procedure from inside SSIS.

cannot query SQL Server system tables over db link created using DG4MSQL

I am trying to create db link from Oracle 11g to SQL Server 2005 using DG4MSQL gateway.
After creating db link I am not able to query SQL Server system views (sys.services or sys.objects) using JDBC driver, but I am able to query all user tables using JDBC driver.
If I use sqlplus, I am able to query all tables including system tables. Since my project is Java project, I am bound to use JDBC driver.
One more observation I made is that, if I use DG4ODBC instead of DG4MSQL gateway, then I am able to query all SQL Server tables including system tables using JDBC driver.
Please let me know if there are any ways I can query SQL Server system tables using DG4MSQL and JDBC driver?
this one is a little bit tricky to explain
An Oracle Gateway performs 3 types of operations:
SQL translations (when you query regular tables, views etc)
Data Dictionary translations (when you query system views)
Data Type transformations (for example Microsoft's date to Oracle's date)
In case of JDBC, the JDBC-ODBC bridge makes the JDBC driver perfectly compatible with the drivers included in DG4ODBC. Therefore, JDBC plus DG4ODBC allows you to perform all the transformations above.
The problem is that DG4MSQL uses a proprietary driver and only SQL translations can be bridged to JDBC.
As a solution to your issue, you could try to create local views on your Oracle schema, based on the remote SQL server system views. Depending on your requirements, you can even create them as materialized views.
CREATE OR REPLACE VIEW sys_services
AS SELECT *
FROM sys.services#dblink;
and then query sys_services instead of directly querying sys.services#dblink

Resources