I'm trying to set up a JDBC connection pool (WITH username and password)
However, the the schema name (which obviously wasn't set up by myself) was named something else and NOT the same as the username. Therefore, when my Glassfish web app runs, I got "unknown table or view" error.
I figure I can address this by hard-coding the schema on each and everyone of my entity classes, BUT I was wondering if there's a way to specify this in either in the JDBC connection pool or the JDBC resource that my application is using.
Related
I have a java application which runs on IBM i. It creates connection to AS400 database using jdbc. It does not specify the database name in JDBC connection URL, means it creates connection to default system database associated with *SYSBAS.
Now I want my application to run on iASP. When running on iASP it fails to connect to database.
IBM i documentation says that we must specify RDB name in "database name" property of jdbc connection URL to connect.
problem here is that,
IBM i documentation says by default RDB name of iASP group is same as primary iASP device name in iASP group. But it can be assigned different name.
I am able to retrieve iASP group name and iASP device name programmatically using JTOPEN(by calling API QUSROBJD). Which means my application will work in default scenario. But when RDB name is assigned different name then my application may fail. I want to retrieve RDB name associated with iASP.
How can I retrieve correct RDB name for an iASP?
I tried using API QUSRJOBI, but it is returning database name as blank.
There are two types of Auxiliary Storage Pool (ASP) on IBM i: System ASPs and independent ASPs (iASP). On DB2 for i, all libraries in the system ASP are treated as a single database and you can qualify tables with a schema name to access a tables in a specific library. According to the documentation that I found, each new iASP creates a new database, and these can be queried in QSYS2.SYSCATALOGS. So you will need a connection to the system database and, from that, you can find the database name and connect to each iASP that you need a connection to. Unfortunately I cannot test this as I do not have an iASP available to me.
I have used the exact same Driver Name, Connection URL , User Name and Password for connecting to my Oracle 11g Express edition database running on my local(same) machine from 2 codes.
Simple Java code to connect to DB and read values from a table.
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:#localhost:1521:xe",
"SYSTEM","Platz#123"
);
In Hibernate persistence.xml
The Simple java connection works as expected, However Hibernate gives me the error "java.sql.SQLException: ORA-01017: invalid username/password; logon denied".
Does this has to do anything with the oracle installation configurations on my machine? Or if it is something else.
Could you please provide and explanation and the way out.
I believe the standard JPA property name for the user name is:
javax.persistence.jdbc.user
Not:
javax.persistence.jdbc.username
I'm trying to run some application and get the following error:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Can't start a cloned connection while in manual transaction mode.
I know that I should add the parameter ;SelectMethod=Cursor to your JDBC URL
But I'm having problem understanding where exactly should I change it? Should it be some conf file in JDBC driver folder somewhere? Or can I do it from sql management studio?
Also is there some easy way to determine if and what version of JDBC driver I have?
Help is very much appreciated!
You specify the URL when creating your JDBC connection, e.g.:
Connection con = DriverManager.getConnection(
"jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]",
username,
password);
Of course you have to replace the stuff in the brackets with your values.
Quite the same is true for every other tool (e.g. IntelliJ, Eclipse) I know of that connects to a DB via JDBC. See e.g. attached screenshot. Here you also specify the connection parameters via the JDBC URL.
I am trying to connect to SQL server 2005 via Workbench/J. I entered everything correctly for the jdbc string and I can connect to the desired server. But, I have to type fully qualified names for a table with database name. I don't want to do that. I set my instanceName to the database and it did not work for me.
Is there a way to connect to the DB instead of just the server ?
jdbc:sqlserver://serverName[\instanceName][:portNumber]
If you want to connect to an instance you need to do two things:
Make sure the SQL Server Browser service is running on your SQL Server host (disabled by default IIRC)
Do not include the portnumber in the connection string if you want to connect by instance name. The JDBC driver will ignore the instance name when the connection string includes a portnumber (each instance has its own port number)
With regard to the second item, the documentation says:
For optimal connection performance, you should set the portNumber when you connect to a named instance. This will avoid a round trip to the server to determine the port number. If both a portNumber and instanceName are used, the portNumber will take precedence and the instanceName will be ignored.
The instance name is not the same thing as your database name. You specify the database name using the connection property databaseName, eg:
jdbc:sqlserver://localhost;databaseName=AdventureWorks
Microsoft SQL Server supports multiple installs on the same computer. Each install ("virtual" SQL Server, if you will) is identified by its "Instance name". So, we could have two separate "SQL Servers" on the same computer, e.g., one instance named \PRODUCTION for the production databases, and another instance named \TEST for a test environment. Each instance operates independently.
A default installation of SQL Server Express Edition creates a SQL Server instance named \SQLEXPRESS. The other Editions of SQL Server normally create a "default instance" (sometimes identified as \).
Each instance of SQL Server can contain multiple databases. You can set the default database for your connection like this:
jdbc:sqlserver://myservername;database=myDb
or
jdbc:sqlserver://myservername;instanceName=instance1;database=myDb
I think you should be able connect to a specific database like this:
jdbc:sqlserver://serverName[\instanceName][:portNumber];databaseName=MyDatabase
I have a problem in establishing DB2 connection with wrong user-name/password. We have an application which runs on LAN on many systems using DB2 database located on my system as well as other systems.
Firstly I use this URL to create other system DB2 connection:
Connection con = DriverManager.getConnection("jdbc:db2://Rahulkcomputer:50000/XAN4", "rahulk", "dbirs#35");
this returns proper Connection object. Now when I change the URL to access my system DB2 connection with same user-name/password as (using same user-name/password is intensely done for checking error handling):
Connection con = DriverManager.getConnection("jdbc:db2://127.0.0.1:50000/XAN4", "rahulk", "dbirs#35");
This time it again returns the Connection object instead of throwing an SQLException specifying wrong user-name/password (due to my system's DB2 authentication is totally different from Rahulkcomputer's system)
After getting connection, I execute this query to check proper user name as explained in post:
Simple DB2 Query for connection validation
SELECT CURRENT SQLID FROM SYSIBM.SYSDUMMY1
(this returns "rahulk" in both cases)
Why DB2 created connection in 2nd case with wrong user-name/password (moreover when we close all the services of DB2 on Rahulkcomputer, even then I get the connection in 2nd case)?
Thanks in Advance.
You either created your database with the restrictive option or revoked the select right to sysibm from PUBLIC. The connection you had was fine, the access rights not. 42704 is DB2's way of saying "huh?", it did not recognize sysibm because you had no rights to see it.