db2 CREATE DATABASE XYZ
db2 DROP DATABASE XYZ
These db2 commands which doesn't provide support to specify username/password while executing on db2cmd/db2clp for a specific user other than machine logged-in user. Hence result a exception
"SQL1092N The requested command or operation failed because the user ID does not have the authority to perform the requested command or operation."
And when the same commands run as by choosing 'Run as different user', it works properly.
- But I need to use same mechanism from Java code, but don't know how. Is it possible to open installed db2's clp as a different user form Java code??
- Is it possible to associate username/password in create/drop commands?
JDBC. These were all forMySQLhowever. SoJDBCcan execute such statements, if it's supported by the database. I also found a post claiming that in DB2 for LUW create database is indeed only available on the command line, while in DB2 for z/OS it's supposed to also work as an SQL statement. I assume he uses DB2 for LUW, but I didn't know beforehand that it doesn't support the command via SQL. So, my bad if I made a useless suggestion.JDBCit's dependent on the subprotocol/drivers if you have to specify a database. You can see this here, for example: docs.oracle.com/javase/tutorial/jdbc/basics/… Apparently DB2 always requires a database in the URL. Which, again, I wasn't aware off beforehand. I just assumed it would work and didn't know the limitations of DB2 in that matter. It would've been valid for a different type of database like MySQL though.