cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to the database in a batch script

Former Member
0 Kudos
4,094

I am unable to connect to my database in a batch script. When I ping it, it fails. But when I open up scjview and connect (either with a connection profile or entering in the username, password, database file, and encryption key) it works. How can I do this sequence just on the commandline to connect and then run a script?

This is what is not working

dbisql -c "uid=DBA;pwd=sql;eng=servername" myscript.sql

This ping also does not work

dbping -d -c "uid=DBA;pwd=sql"

However, if I do this:

dbisql -c "uid=DBA;pwd=sql;eng=servername"

and then manually enter in the database file and encryption key, the previous commands all work. How do I include entering the database file and encyption key to this command?

Accepted Solutions (1)

Accepted Solutions (1)

MarkCulp
Participant

It sounds like you simply need to provide more connection parameters to your -c "..." string.

Take a look here - you likely want to add DBN (database name), DBF (database file), and DBKEY (database encryption key - needed if you are autostarting an encrypted database).

HTH

Answers (1)

Answers (1)

Former Member

The pattern you are describing indicates you desire/require the database to autostart.

It is unfortunate that dbisql won't prompt the connection dialog AND read the cmdline at the same time. I run into that regularily myself. You can always try including DBF= ...; and DBK=...; in your connection string.

The main issue with doing that is your client now knows the decryption key. It is usually better to have the database running as a service and take further measures to protect that key from casual expose.

If you are in the middle of development you could also consider leaving off encrypting your databases until you have real production or user information that needs protection.

If you must autostart the database and provide the encryption key you can consider burying the key inside of a configuration file and reference that in your cmdline as in:

dbisql @at_isql.txt

customizing that file as suited to your needs and combine that with other parameter as needed. The key can then be protected by using dbfhide.