Results 1 to 5 of 5

Thread: java: How to connect data base without dsn

  1. #1

    Thread Starter
    Lively Member softkans's Avatar
    Join Date
    May 2006
    Posts
    70

    java: How to connect data base without dsn

    Hai Guys...
    I just want to know about how to connect the java application to MS-ACCESS or oracle without using the DSN (Data Source Name) name.Is there any drivers we need to install otherwise give the code for this.i will expecting for ur correct answers.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java: How to connect data base without dsn

    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Lively Member softkans's Avatar
    Join Date
    May 2006
    Posts
    70

    Post Re: java: How to connect data base without dsn



    thanks for your reply..

    in your program

    cn=DriverManager.getConnection("jdbcdbc:test","","");

    test is the dsn name

    i want to connect database without dsn name. please give me correct code..

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: java: How to connect data base without dsn

    Sorry...
    This code is created by JBuilder, it uses some pre-compiled borland classes
    Code:
    public class DataModule1 implements DataModule
    {
      /**
       * Data module reference.
       */
      private static DataModule1 myDM ;
      private Database database1 = new Database() ;
      private QueryDataSet addresses = new QueryDataSet() ;
      private QueryDataSet country = new QueryDataSet() ;
    
      /**
       * DataModule constructor.
       */
      public DataModule1 () {
        try {
          jbInit() ;
        }
        catch (Exception exception) {
          exception.printStackTrace() ;
        }
      }
    
      /**
       * Initialize.
       *
       * @throws java.lang.Exception
       */
      private void jbInit () throws Exception {
        database1.setConnection(new ConnectionDescriptor("jdbc:borland:dslocal:D:\\Borland\\JBuilder2006\\samples\\JDataStore\\datastores\\employee.jds",
            "Sample", "", false, "com.borland.datastore.jdbc.DataStoreDriver")) ;
        addresses.setQuery(new QueryDescriptor(database1,
                                               "SELECT ADDRESSES.FIRST_NAME,ADDRESSES.LAST_NAME,ADDRESSES.ADDRESS,ADDRESSES.CITY,ADDRESSES.STATE,ADDR" + "ESSES.ZIP FROM ADDRESSES", null, true,
                                               Load.ALL)) ;
        country.setQuery(new QueryDescriptor(database1,
            "SELECT COUNTRY.COUNTRY,COUNTRY.CURRENCY FROM COUNTRY", null, true,
                                             Load.ALL)) ;
      }
    
      /**
       * Get data module reference.
       *
       * @return DataModule reference
       */
      public static DataModule1 getDataModule () {
        if (myDM == null) {
          myDM = new DataModule1() ;
        }
        return myDM ;
      }
    
      public Database getDatabase1 () {
        return database1 ;
      }
    
      public QueryDataSet getAddresses () {
        return addresses ;
      }
    
      public QueryDataSet getCountry () {
        return country ;
      }
    }
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: java: How to connect data base without dsn

    Uh, why?

    No, it's not possible to connect to anything using JDBC without a DSN. (Unless you use a preconfigured data source, but then the configuration of that source probably used a DSN.) Why would you want to do such a thing?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width