Create Datasource programatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • myusernotyours
    New Member
    • Nov 2007
    • 188

    #1

    Create Datasource programatically

    Hi!
    I want to access a database (ms access) without having to create a datasource from the control panel. Can i create a datasource dynamically so that my users only need to specify the path?
    help will be really good!
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Have you looked at using JDBC so you can just specify the URL of the database, and do not have to specify it every time.

    Comment

    • myusernotyours
      New Member
      • Nov 2007
      • 188

      #3
      Originally posted by pronerd
      Have you looked at using JDBC so you can just specify the URL of the database, and do not have to specify it every time.
      Am using jdbc odbc bridge I specify the url as follows. "jdbc:odbc:data sourceName" where datasourceName is the name of the datasource. I want to be able to use the path to the access database instead of the datasource name.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by myusernotyours
        Am using jdbc odbc bridge I specify the url as follows. "jdbc:odbc:data sourceName" where datasourceName is the name of the datasource. I want to be able to use the path to the access database instead of the datasource name.
        Normally it doesn't work that way with DataSources; a DataSource binds itself
        to a name using the JNDI mechanism just to circumvent that a client has to
        knot absolute paths etc. The client just asks the JNDI mechanism for a name
        and it'll return the bound DataSource.

        kind regards,

        Jos

        Comment

        • myusernotyours
          New Member
          • Nov 2007
          • 188

          #5
          Originally posted by JosAH
          Normally it doesn't work that way with DataSources; a DataSource binds itself
          to a name using the JNDI mechanism just to circumvent that a client has to
          knot absolute paths etc. The client just asks the JNDI mechanism for a name
          and it'll return the bound DataSource.

          kind regards,

          Jos

          I don't understand. It's a desktop application and I don't want users to create a datasource from the control panel. Can you post some code.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by myusernotyours
            I don't understand. It's a desktop application and I don't want users to create a datasource from the control panel. Can you post some code.
            Look up JNDI like has been suggested and read on how register and access datasources using JNDI. Asking for code is almost always the wrong thing to do here.

            Comment

            • myusernotyours
              New Member
              • Nov 2007
              • 188

              #7
              Originally posted by r035198x
              Look up JNDI like has been suggested and read on how register and access datasources using JNDI. Asking for code is almost always the wrong thing to do here.

              Thanks. I will look that up. The reason I asked for code is coz I thot it was a simple matter with a straight forward example. I will look that up.

              regards.

              Comment

              Working...