0

I can not figure out the correct syntax for my properties. Any sugestions? This 4 lines are in my config.properties

 url=jdbc:sybase:Tds:localhost:2638?servicename=db
 driver=com.sybase.jdbc4.jdbc.SybDataSource
 username=myUserName
 password=myPass

I have tried several ways ... with no luck?

and my mybats-config.xml is as folow.

    <environment id="development">
        <transactionManager type="JDBC" />
        <dataSource type="POOLED">  
            <property name="driver" value="${driver}" />
            <property name="url" value="${url}" />
            <property name="username" value="${username}" />
            <property name="password" value="${password}" />
        </dataSource>
    </environment>
user1416776
  • 99
  • 2
  • 11
  • I don't have a Sybase db to test against, so a couple of questions: 1) what is the error you are getting? 2) do the Sybase url/username/password, etc. work with a straight JDBC connection (not using MyBatis)? – quux00 Jun 30 '12 at 13:27

1 Answers1

0

You need to have an <environments> element around the <environment> xml block you have above. Do you have one and just didn't show it? If not, add that and it should work (assuming the rest of your config properties are set up correctly).

<environments>
  <environment id="development">
    <transactionManager type="JDBC" />
    <dataSource type="POOLED">  
      <property name="driver" value="${driver}" />
      <property name="url" value="${url}" />
      <property name="username" value="${username}" />
      <property name="password" value="${password}" />
    </dataSource>
  </environment>
</environments>

Also, in case it helps, the order of xml elements in the MyBatis XML config is important, it has to be:

  • properties
  • settings
  • typeAliases
  • typeHandlers
  • objectFactory
  • plugins
  • environments
    • environment
      • transactionManager
      • dataSource
  • databaseIdProvider
  • mappers

So make sure you are following that pattern as well.

quux00
  • 13,679
  • 10
  • 57
  • 69
  • Thnks for your input midpeter444! Becouse I got no error output but no rows in my view list I assumed somthing was wrong with db connection, but it was not. My error was related to not having my files in same package and the code was ok (and I hade the enviroments tag as yous mentioned). Thanks for your input! – user1416776 Jul 31 '12 at 13:27