Servelt Database Connectivity: JDBC, ODBC, Connection Pooling and - database

For an exam question, I am looking at the various ways in which a servlet can make a connection to a database connection. So far I have
JDBC
ODBC
Database Pooling
But the question asks for 4, and I cannot seem to find the 4th alternative. Does it actually exist?

I suspect you might want to look at the Java Persistence API. Go Google JPA.

I would add JNDI lookup and connecting directly using DriverManager. And what is database pooling? Do you mean connection pooling?
On the other hand if they are asking about high-level technologies: jdbc -> mybatis -> hibernate -> jpa.

A servlet can't really use ODBC it might be able to use a JDBC via ODBC driver, but the servlet sees only ODBC.
Similarly Connection Pooling just pools JDBC connections. The connections are just made via JDBC.
Since the expected answer is 4 they might be asking for the 4 types of JDBC drivers

Related

Does MSSQL JDBC utilize server aliases

I am preparing for a SQL Server database migration. I would like to use the alias functionality from the SQL Server Native Client, configured with cliconfg.exe, to redirect my client applications to the new server. I am using this in conjunction with DNS aliases so I can redirect the connection to a new port. However, my applications use MSSQL JDBC instead of the native client.
Does MSSQL JDBC use the alias settings from the native client? Is it, by chance, a wrapper over the native client functionality? Both are provided by Microsoft. If not, does MSSQL JDBC have an equivalent client-hosted server name redirect functionality? How is this configured?
I did some preliminary testing with the native client settings and it seems like the JDBC driver does not utilize the alias. However, the naming schemes are a bit different between the two so I may not have had the names correct. I am referring to jdbc:sqlserver://servername:port compared to servername,port in the alias tool.
I asked the mssql-jdbc team and at this time (Dec 2022) the driver does not support aliases.

Connect SymmetricDS to ParaSQL

We're trying to test loading data from our on-premise SQL Server 2008R2 machine to ParaSQL using SymmetricDS. We have a dedicated server instance with ParaSQL which requires an SSL connection. Certificates are provided by ParaSQL.
Where we're stuck is how to configure SymmetricDS to use secure socket layer for this connection. We can find some info in the documentation on how to generate keys on our end, but nothing on how to connect using provided certificates.
Does anyone here have any experience with that?
Thanks in advance.
With SymmetricDS there is an SSL connection between the SymmetricDS nodes, and a different one between the JDBC driver and the database itself. The keys you are generating sound like they are for the node-to-node SSL. I believe what you need to do is setup the ParaSQL supplied SSL certificates for the JDBC driver that is making the connection to the database.

Connecting to DB2 through ODBC is extremely slow

I am experiencing extremely slow connections to a local DB2 (v9.7 Express-C) database through ODBC on a Windows 7 system (x64). I wrote several test programs, each connecting to a local database for 100 times in a row (without querying) and measuring the time. Results are:
C++ x86 DB2/ODBC: 32bit C++ application, connecting to a local DB2 database via CDatabase
C++ x86 DB2/ODBC: same as above, but x64 application
PHP DB2/ODBC: Connecting to a local DB2 database via odbc_connect.
PHP MySQL/ODBC: Connecting to a local MySQL database via odbc_connect.
JDBC DB2: Java application, connecting to a local DB2 database using the DB2 JDBC driver.
JDBC MySQL: Java application, connecting to a local MySQL database using the MySQL JDBC driver.
My first thought was that something's wrong with my ODBC configuration, but as you can see connecting to a MySQL database through ODBC works like charm. On the other hand, connecting to DB2 with the JDBC driver instead of ODBC works fine too (although it's still a lot slower than MySQL).
I found this related question, but it does not apply to me.
Any hints on what might be causing this and how to resolve would be great!
Supplementary question: What are common connection times when connecting to a DB2 database through ODBC? Is it normal for the DB2 ODBC driver to be so slow?!
One thing that you should look at is the database activation. DB2 activates the database upon the first connection and deactivates it when the last connection is closed. During activation DB2 allocates transaction log files, memory pools, and performs a number of other tasks that take time.
This behaviour does not depend on the type of connection (ODBC or JDBC); the difference you observe might be explained by an extra connection that keeps the database active during your JDBC tests.
Try issuing ACTIVATE DB <YOURDB> before your tests, which will keep the database active even in the absence of connections. There is no way to activate databases by default, apart from issuing this command upon the system startup, e.g. from a batch file.

Does Entity Framework use database connection pooling? and is it by default?

I have been searching for a while about how EF utilizes connections to SQL Server DB, and whether it is using Connection pools under the hood, but I couldn't find any details about that.
Connection pooling is handled by the underlying datasource provider, and not by the Entity Framework. The MS SQL provider, for example, supports and uses connection pooling by default.
Using Connection Pooling with SQL Server
is a good reference.

Can I share a single database connection between ODBC and ADO?

Is it possible to have an ODBC connection and an ADO connection share the same underlying SQL Server connection, so that both are using the same SPID?
Currently I am using SQLDriverConnect and ADODB::_ConnectionPtr->Open. I can make these connections in either order, so perhaps it's possible to open one making use of the other?
(Language is C++, database is SQL Server 2005 & 2008. ODBC connection string uses a DSN. ADO uses Provider=SQLNCLI10, but either could be changed if required).
ADO uses OleDB, so you cannot share a connection with ODBC. Even if you use the ADO provider for ODBC you still wont be able, as no ADO API allows to wrap an existing ODBC connection handle.
But the real question is: why do you want to share the connection? The only valid reason is to enroll the two connections in the same transaction without doing a loopback local distributed transaction. Enrolling two distinct connections in the same transaction was always possible, this is how MTS and COM+ worked. The first connection uses sp_getbindtoken to get an enrolment token and the second connection uses sp_bindsession to enroll itself. This mechanism is on the endangered list of deprecation, but after all you are asking about the technology of the 90s... (ODBC, ADO)

Resources