Re: creating tables and dynamic configiration
1) iBatis does not support DDL script execution. 2) http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+connect+using+a+user%27s+credentials%3F Brandon On 6/9/05, Dmitry Skavish [EMAIL PROTECTED] wrote: Hello everybody, I am pretty new to iBATIS, but already love it! I have couple of questions: 1. I am developing a client app which will be using iBatis. On the first run I want to create tables in a db if they are not there yet. Can I use iBatis for that? If yes how? Basically I need to send a bunch of create table ... in one transaction. Currently I get connection manually from jdbc and then create stmt and create all those tables. I would prefer to do it via iBatis the same way I query or update it. Another related problem is that i was trying to obtain connection from iBatis using this code: SqlMapClient map map.startTransaction(); Connection connection = map.getCurrentConnection(); createDB(connection); map.endTransaction(); but it fails on the first sql, some noninformant jdbc exception saying that transaction is aborted without any clue why. I use postgress db. 2. How do I pass connection properties, i.e. user, password, in runtime. I mean I don't want it to be hardcoded in xml config. Thanks! -- Dmitry Skavish
Re: creating tables and dynamic configiration
1) iBatis does not support DDL script execution. Are there any plans to support this? 2) http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+connect+using+a+user%27s+credentials%3F It seems to be an overkill for such simple thing. If this is the only way? I would rather generate xml and give it to iBatis than doing what is suggested there. Brandon On 6/9/05, Dmitry Skavish [EMAIL PROTECTED] wrote: Hello everybody, I am pretty new to iBATIS, but already love it! I have couple of questions: 1. I am developing a client app which will be using iBatis. On the first run I want to create tables in a db if they are not there yet. Can I use iBatis for that? If yes how? Basically I need to send a bunch of create table ... in one transaction. Currently I get connection manually from jdbc and then create stmt and create all those tables. I would prefer to do it via iBatis the same way I query or update it. Another related problem is that i was trying to obtain connection from iBatis using this code: SqlMapClient map map.startTransaction(); Connection connection = map.getCurrentConnection(); createDB(connection); map.endTransaction(); but it fails on the first sql, some noninformant jdbc exception saying that transaction is aborted without any clue why. I use postgress db. 2. How do I pass connection properties, i.e. user, password, in runtime. I mean I don't want it to be hardcoded in xml config. Thanks! -- Dmitry Skavish -- Dmitry Skavish
Re: creating tables and dynamic configiration
Dmitry, you can still use the ThreadLocal strategy without the connection pool stuff. In a client side app i am assuming you would only need one connection. So, you could write your own datasource factory that implements the DataSourceFactory interface and your own DataSource which implements the DataSource interface. Then you could configure it in a JDBC transaction manager in your sqlMapConfig.xml files. example config transactionManager type=JDBC dataSource type=my.custom.datasourcefactory.MyClass property name=Username value=${driver}/ property name=Password value=1/ /dataSource /transactionManager Brandon On 6/9/05, Dmitry Skavish [EMAIL PROTECTED] wrote: Let me explain. I am developing a client side app, that is with gui and such, not a web app. The app will be querying/updating db as part of what it's doing. When the app starts it would prompt a dialog asking user to enter username/password. This username/password will be used to access the db. I don't use any connection pool because there will be exactly one connection. So basically I need to pass these user/pwd to ibatis at runtime. Currently they are hardcoded in ibatis xml resource. That's why I mentioned generation of this xml. I can parse it, replace some properties (that is user/pwd) and feed it to ibatis. I consider it to be a hack and if there is a better workaround I would prefer to use it. I hope it's clear. Thanks! #2 I'm not sure what xml generation has to do with this issue. Maybe i am misunderstanding you. If you are developing a web application you will have to do something like what was provided if you want individuals to use their own username and password for database access. Considering you work with connection pools there is no easy way to add a username and password to the connection and maintain security without doing what the link mentioned. So, this is not an issue with iBatis as much as it is an issue with pooled connections. Brandon On 6/9/05, Dmitry Skavish [EMAIL PROTECTED] wrote: 1) iBatis does not support DDL script execution. Are there any plans to support this? 2) http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+connect+using+a+user%27s+credentials%3F It seems to be an overkill for such simple thing. If this is the only way? I would rather generate xml and give it to iBatis than doing what is suggested there. Brandon On 6/9/05, Dmitry Skavish [EMAIL PROTECTED] wrote: Hello everybody, I am pretty new to iBATIS, but already love it! I have couple of questions: 1. I am developing a client app which will be using iBatis. On the first run I want to create tables in a db if they are not there yet. Can I use iBatis for that? If yes how? Basically I need to send a bunch of create table ... in one transaction. Currently I get connection manually from jdbc and then create stmt and create all those tables. I would prefer to do it via iBatis the same way I query or update it. Another related problem is that i was trying to obtain connection from iBatis using this code: SqlMapClient map map.startTransaction(); Connection connection = map.getCurrentConnection(); createDB(connection); map.endTransaction(); but it fails on the first sql, some noninformant jdbc exception saying that transaction is aborted without any clue why. I use postgress db. 2. How do I pass connection properties, i.e. user, password, in runtime. I mean I don't want it to be hardcoded in xml config. Thanks! -- Dmitry Skavish -- Dmitry Skavish -- Dmitry Skavish
Re: creating tables and dynamic configiration
Ooooh, Ok. Use the SqlMapClient's buildSqlMapClient(Reader reader, Properties props) method. You can pass in the properties at runtime that way. Larry On 6/9/05, Brandon Goodin [EMAIL PROTECTED] wrote: -- Forwarded message -- From: Dmitry Skavish [EMAIL PROTECTED] Date: Jun 9, 2005 3:35 PM Subject: Re: creating tables and dynamic configiration To: Brandon Goodin [EMAIL PROTECTED] Let me explain. I am developing a client side app, that is with gui and such, not a web app. The app will be querying/updating db as part of what it's doing. When the app starts it would prompt a dialog asking user to enter username/password. This username/password will be used to access the db. I don't use any connection pool because there will be exactly one connection. So basically I need to pass these user/pwd to ibatis at runtime. Currently they are hardcoded in ibatis xml resource. That's why I mentioned generation of this xml. I can parse it, replace some properties (that is user/pwd) and feed it to ibatis. I consider it to be a hack and if there is a better workaround I would prefer to use it. I hope it's clear. Thanks! #2 I'm not sure what xml generation has to do with this issue. Maybe i am misunderstanding you. If you are developing a web application you will have to do something like what was provided if you want individuals to use their own username and password for database access. Considering you work with connection pools there is no easy way to add a username and password to the connection and maintain security without doing what the link mentioned. So, this is not an issue with iBatis as much as it is an issue with pooled connections. Brandon On 6/9/05, Dmitry Skavish [EMAIL PROTECTED] wrote: 1) iBatis does not support DDL script execution. Are there any plans to support this? 2) http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+connect+using+a+user%27s+credentials%3F It seems to be an overkill for such simple thing. If this is the only way? I would rather generate xml and give it to iBatis than doing what is suggested there. Brandon On 6/9/05, Dmitry Skavish [EMAIL PROTECTED] wrote: Hello everybody, I am pretty new to iBATIS, but already love it! I have couple of questions: 1. I am developing a client app which will be using iBatis. On the first run I want to create tables in a db if they are not there yet. Can I use iBatis for that? If yes how? Basically I need to send a bunch of create table ... in one transaction. Currently I get connection manually from jdbc and then create stmt and create all those tables. I would prefer to do it via iBatis the same way I query or update it. Another related problem is that i was trying to obtain connection from iBatis using this code: SqlMapClient map map.startTransaction(); Connection connection = map.getCurrentConnection(); createDB(connection); map.endTransaction(); but it fails on the first sql, some noninformant jdbc exception saying that transaction is aborted without any clue why. I use postgress db. 2. How do I pass connection properties, i.e. user, password, in runtime. I mean I don't want it to be hardcoded in xml config. Thanks! -- Dmitry Skavish -- Dmitry Skavish -- Dmitry Skavish