Creating SQLSessionFactory using Sql Connection

12 views
Skip to first unread message

yaog

unread,
Jul 9, 2019, 2:40:02 AM7/9/19
to mybatis-user
I have a utility that gets an sql connection from another library.
Is there a "right" way to create an SqlSessionFactory based on a provided (by api) sql connection pool and not rely on db loging from within mybatis OR by providing a sql Driver on the other hand?

Guy Rouillier

unread,
Jul 9, 2019, 3:42:31 AM7/9/19
to mybatis-user
See SqlSessionFactory.openSession(Connection connection).

--
Guy Rouillier

On 7/9/2019 2:40:02 AM, "yaog" <yair...@gmail.com> wrote:

I have a utility that gets an sql connection from another library.
Is there a "right" way to create an SqlSessionFactory based on a provided (by api) sql connection pool and not rely on db loging from within mybatis OR by providing a sql Driver on the other hand?

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/eb234eb2-b2bd-4c85-8c1c-6c3f60192109%40googlegroups.com.

Yair Ogen

unread,
Jul 9, 2019, 3:44:51 AM7/9/19
to mybati...@googlegroups.com
 Thanks, would this mean I can skip data source creation in the environment?

And I assume this would mandate me handling connection pooling myself, right?

You received this message because you are subscribed to a topic in the Google Groups "mybatis-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mybatis-user/OPCXVnHFyEE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/em78b1f0ee-5168-4761-8a55-470d063cf5e6%40asus.

Guy Rouillier

unread,
Jul 9, 2019, 4:03:48 AM7/9/19
to mybati...@googlegroups.com
Correct.  You simply supply a java.sql.Connection, however you choose to obtain one. You are not restricted, so yes, you *may* skip data source creation in the environment, if you wish.  And no, nothing is mandating that you handle connection pooling.  For example, if this is a one time requirement, you don't need a connection pool at all, simply create a Connection using DriverManager.getConnection().  On the other hand, if you running an environment that already has connection pools (e.g., Tomcat or JBoss), then you can simply obtain a connection from those existing pools.

--
Guy Rouillier

Yair Ogen

unread,
Jul 10, 2019, 1:56:36 AM7/10/19
to mybati...@googlegroups.com
That won't work for me. I have table with dynamic names, I need to run the code when I provide the sql connection my self since the login for some db's on customer site are complex using kerberos anf other means of authentications. So - I have to find a lib which has java api that I can interact with.

Regards,

Yair

Reply all
Reply to author
Forward
0 new messages