Creating SQLSessionFactory using Sql Connection

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating SQLSessionFactory using Sql Connection

yaog
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/eb234eb2-b2bd-4c85-8c1c-6c3f60192109%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Creating SQLSessionFactory using Sql Connection

Guy Rouillier-2
See SqlSessionFactory.openSession(Connection connection).

--
Guy Rouillier

On 7/9/2019 2:40:02 AM, "yaog" <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/eb234eb2-b2bd-4c85-8c1c-6c3f60192109%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/em78b1f0ee-5168-4761-8a55-470d063cf5e6%40asus.
Reply | Threaded
Open this post in threaded view
|

Re: Creating SQLSessionFactory using Sql Connection

yaog
 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?

On Tue, 9 Jul 2019, 10:42 Guy Rouillier, <[hidden email]> wrote:
See SqlSessionFactory.openSession(Connection connection).

--
Guy Rouillier

On 7/9/2019 2:40:02 AM, "yaog" <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/eb234eb2-b2bd-4c85-8c1c-6c3f60192109%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/em78b1f0ee-5168-4761-8a55-470d063cf5e6%40asus.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CAMWFgdjciGVD%2BNpVZVyf%3DvMNOL7_7B3OTdNXVAgOoMKRSU%3DZ1w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re[2]: Creating SQLSessionFactory using Sql Connection

Guy Rouillier-2
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

On 7/9/2019 3:44:36 AM, "Yair Ogen" <[hidden email]> wrote:

 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?

On Tue, 9 Jul 2019, 10:42 Guy Rouillier, <[hidden email]> wrote:
See SqlSessionFactory.openSession(Connection connection).

--
Guy Rouillier

On 7/9/2019 2:40:02 AM, "yaog" <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/eb234eb2-b2bd-4c85-8c1c-6c3f60192109%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/em78b1f0ee-5168-4761-8a55-470d063cf5e6%40asus.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CAMWFgdjciGVD%2BNpVZVyf%3DvMNOL7_7B3OTdNXVAgOoMKRSU%3DZ1w%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/em66d2f74c-999f-4553-8db3-2bbb43ab7648%40asus.
Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: Creating SQLSessionFactory using Sql Connection

yaog
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

On Tue, Jul 9, 2019 at 11:03 AM Guy Rouillier <[hidden email]> wrote:
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

On 7/9/2019 3:44:36 AM, "Yair Ogen" <[hidden email]> wrote:

 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?

On Tue, 9 Jul 2019, 10:42 Guy Rouillier, <[hidden email]> wrote:
See SqlSessionFactory.openSession(Connection connection).

--
Guy Rouillier

On 7/9/2019 2:40:02 AM, "yaog" <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/eb234eb2-b2bd-4c85-8c1c-6c3f60192109%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/em78b1f0ee-5168-4761-8a55-470d063cf5e6%40asus.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CAMWFgdjciGVD%2BNpVZVyf%3DvMNOL7_7B3OTdNXVAgOoMKRSU%3DZ1w%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/em66d2f74c-999f-4553-8db3-2bbb43ab7648%40asus.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CAMWFgdgkjLTapF0cyyZqOJaZchr_xyfnjZJeKnpbJBHjRYo6gA%40mail.gmail.com.