JDBC Query to connect to MySql Database

Sravani36
Tera Expert

Hi I have a script file where we need to execute this query commands on Mysql database server.

And our instance is integrated with jdbc and now may I know how to connect with Database and where can I place this script file so that to get the output.

Thanks in advance

5 REPLIES 5

Rahul Priyadars
Giga Sage
Giga Sage

Using JDBC connection - you can run a sql query and get its out put not the Script file.

JDBC query can be executed using Data Source-

find_real_file.png

Sample JDBC Query in data source

find_real_file.png

Regards

RP

Hi Rahul,

any idea on how we can execute this script on mysql database, below is my script 

set time on
set sqlprompt "_user 'ON' _connect_identifier':'_date> "
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP OFF
set pages 30000
COLUMN spool_file_log NEW_VALUE spool_file_log
SELECT  DB_UNIQUE_NAME||'_AUDIT_EVIDENCE_'||'_'||TO_CHAR(SYSDATE , 'DDMONYYYY_HH24MISS')||'.html' spool_file_log from v$database;
SPOOL &spool_file_log
SELECT to_char(SYSDATE,'DD-MON-YYYY HH12:MI:SS AM') Report_Generate_AT FROM DUAL;
SELECT NAME,OPEN_MODE FROM V$DATABASE;
SELECT INST_ID,INSTANCE_NAME,HOST_NAME FROM GV$INSTANCE;
SELECT COUNT(*),USERNAME,INST_ID FROM GV$SESSION WHERE USERNAME IS NOT NULL GROUP BY USERNAME,INST_ID ORDER BY INST_ID;
SHOW PARAMETER AUDIT;
SELECT * FROM DBA_USERS ORDER BY USERNAME;
select PROFILE,RESOURCE_NAME,RESOURCE_TYPE,LIMIT from dba_profiles where RESOURCE_TYPE like 'PASSWORD%' order by PROFILE;
set long 1000
select '<PRE>'||DBMS_METADATA.GET_DDL('FUNCTION','DC_PASSWD_VERIFY_FUNCTION','SYS')|| '</PRE>' from DUAL;
SELECT * FROM DBA_SYS_PRIVS ORDER BY GRANTEE;
SELECT * FROM DBA_ROLE_PRIVS ORDER BY GRANTEE;
SELECT * FROM DBA_TAB_PRIVS where GRANTEE in (select username from dba_users where profile in ('DC_SUPPORT_PROFILE','DC_USER_PROFILE')) ORDER BY GRANTEE;
spool off

Hi Rahul,

we have multiple servers to execute a query but here the server is static is there a way how to make this dynamic.

find_real_file.png

Query will run against a given DB not Servers. I may think of server name may go in where clause of the query.

The Server Details given in Screen Shot is the Server where database is running.

Regards

RP