How to connect Java with Acces (DSN Less)

Hi, I'm try to connect an Access DataBase in Java with an example. I find it in this forum, but don't work...
I've my database in the folder Data, and its name is BaseDat.mdb...
I'm working in NetBeans 5.5, and the DataBase is in the Folder: "C:/Documents and Settings/MetalTux/POOL/src/Data/BaseDat.MDB"...
This way, its work, but It's another way to use this... without the "C:/Documents and Settings/MetalTux/POOL/src/"????
Please help me... and sorry my english...
Regards...

I have this in my code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conec = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Documents and Settings/MetalTux/POOL/src/Data/BaseDat.MDB");
This is OK... work in my code...
But I want to know if there's another way to do this... without "C:/Documents and Settings/MetalTux/POOL/src" code....
In Visual Basic I do this with "App.Path", but I don't know how I can do the same thing in Java...
Please help me...

Similar Messages

  • How to connect java with oracle

    can any body show me the code of how to connect java with oracle database.
    thank you

    To configure Oracle JDBC:
    1. Add Oracle JDBC JAR file classes12.zip or ojdbc14.zip to classpath.
    2. Load and register the JDBC driver.
    Class.forName("oracle.jdbc.driver.OracleDriver");
    3. Obtain a connection:
    String url="jdbc:oracle:thin:@<host>:1521:<database>
    Connection con = DriverManager.getConnection(url,
    "myLogin", "myPassword");
    4. Create a SQL statement.
    Statement stmt = con.createStatement();
    5. Obtain a result set.
    ResultSet rs = stmt.executeQuery(
    "SELECT ...");

  • How to connect java with database without any dsn.

    is there any way to connect java with database with out creating any dsn..like we do in ado in vb by providing provider.

    Sure use a type 4 driver. No DSN.

  • How to connect java with C

    Plz help....
    How to Connect a Java With C ....

    using the JNI, Java Native Interface. there are tons of tutorials on the web about it, that will explain far better and more completely than a few posts on a forum

  • How can connect java with 3D Max

    i want to make 3d maze by reading from text file
    for example when i read 0, then i draw wall
    when i read 1 i draw path ..and so on
    and i want to move the object in the maze by using AI techniques
    my questions are:
    - can I read from file and draw by using 3D Max and program the
    object moving using java, if yes, how can i connect the java and 3D Max
    if there are any resoures, or any other silution may help me
    please tell me about it

    I've found two loaders to load 3ds files, so if you export your models from 3ds max that should work.
    http://www.starfireresearch.com/services/java3d/inspector3ds.html
    http://sourceforge.net/projects/java3dsloader/
    //My hyperlink option doesn't work today
    Hope it helps.
    //Considerate

  • How to connect Java to crystal report

    How to connect java with crystal report ?
    Which are the API's for that

    In all this time you never considered searching?
    Cross post
    http://forum.java.sun.com/thread.jspa?threadID=791154

  • Connecting JAVA with  Video Card

    Hai,...
    Can someone tell me how to connect Java with a video card (like Matrox, dec-link, etc)?
    Because i want to display a video using that video card to a TV monitor.
    Is there any tutorial about this? and about connecting JAVA with other device?
    Thank you,
    Billy

    Hai,...
    Can someone tell me how to connect Java with a video card (like Matrox, dec-link, etc)?
    Because i want to display a video using that video card to a TV monitor.
    Is there any tutorial about this? and about connecting JAVA with other device?
    Thank you,
    Billy

  • How to connect Java Application with database!

    Dear all, now I am create a dababase application. My database use JData Store. But I don't know how to connect application with it. Can you tell me this proplem?
    Thank!

    Do a google search for JDBC, or go buy a book.
    You will need a JDBC driver which supports your database. Or you might be able to use the JDBC-ODBC bridge if there's an ODBC driver for your database.

  • How to connect Java and Microsoft SQL Server 2000

    hi,
    could anyone please teach me how to connect Java and SQL Sever 2000?? if possible could you guys provide me with an example??? i could hardly find any relevant resources about it...
    Thanks ~!

    thanks for the information...
    by the way hv any working module on it?? i'm new to
    both Java and Microsoft SQL Server... Thanks againFirst things first... you should read this:
    http://java.sun.com/docs/books/tutorial/jdbc/
    This is microsofts official JDBC Driver: http://www.microsoft.com/sql/downloads/jdbcregister.asp
    Install it and the documentation has some usage examples

  • An error occured when connecting java with Ms Access

    Hello Everybody
    I am a new developer in java and want to connect java with Microsoft Access
    i am using JCreator LE
    My code is to insert 3 records for 3 members and then save them in DB and retrieve the information
    Here is the code
    import java.sql.*;
    public class Project3 {
        public static void main(String[] args) {
             try {
                  System.out.println("Beginning Connection");
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String accessFileName = "Information";
                String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
                Connection con = DriverManager.getConnection( connURL ,"","");
                Statement stmt = con.createStatement();
                System.out.println("Connection done successfully");
                stmt.execute("Create table Member(Name String,ID Integer)");
                stmt.execute("insert into Member values ('Joe','1234')");
                stmt.execute(" select * from Member");
                ResultSet rs=stmt.getResultSet();
                if (rs != null)
                     while (rs.next()){
                          System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
                stmt.close();
                con.close();
                catch (Exception e) {
                System.out.println("An error Occurred in Connecting with the DB " );
    }and the error is
    Beginning Connection
    Connection done successfully
    An error Occurred in Connecting with the DB
    it didn't insert information in the DB

    Well, thank u i have traced the error and fx it
    but
    how to modify the code and keep the user entering 3 values and search for the entered values??
    Here is the correct code
    import java.sql.*;
    public class Project3 {
        public static void main(String[] args) {
             try {
                  System.out.println("Beginning Connection");
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String accessFileName = "jdbc:odbc:Project";
                String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
                Connection con = DriverManager.getConnection( accessFileName);
                Statement stmt = con.createStatement();
                System.out.println("Connection done successfully");
                stmt.execute("Create table Member(Name String,ID Integer)");
                stmt.execute("insert into Member values ('Joe','1234')");
                stmt.execute(" select * from Member");
                ResultSet rs=stmt.getResultSet();
                if (rs != null)
                     while (rs.next()){
                          System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
                stmt.close();
                con.close();
                catch (Exception err) {err.printStackTrace();}
    }

  • How to connect Java into BarTender Label Printing Software

    Hi,
    I have one problem, my company have bartender label printing software 32 bit version, previously they use VB6 for controlling the dublicate printing of lable,but the software is gone. Now i want to do this in Java, but i don't know how to connect java into Bartender software.
    my company using old version, it accept only VB6. My Boss said can buy new Bartender Software but i don't know how to link and control dublicate printing. if anybody knows this connection between Bartender and Java please help me.
    if bartender New version support this features please send the link and example source code please help me.
    AnbuAathi

    Hi , i have the similar task ,where i need to connect my web portal application with the bartender software .I did a hugh R&D to integrate Java application with Bartender software but did not find any luck .So i request to provide the needed help to integrate my Java Application with Bartender software .
    Thanks in Advance
    Mohan

  • Unable to connect JAVA with Oracle

    I have jdk1.6 and oracle installed on my machine but unable to connect java with database
    have classes12.jar and ojdbc14.jar
    my environmental variables in respect to this are :
    JAVA_HOME= C:\Java\jdk1.6.0_04
    JRE_HOME=C:\Java\jdk1.6.0_04
    PATH=J:\oracle\ora92\lib;
    J:\oracle\ora92\bin;
    C:\Program Files\Oracle\jre\1.3.1\bin;
    C:\Program Files\Oracle\jre\1.1.8\bin
    CLASSPATH=J:\oracle\ora92\jdk\jre\bin\JdbcOdbc.dll;
    J:\oracle\ora92\jdbc\lib\classes12.jar;
    J:\oracle\ora92\jdbc\lib\ojdbc14.jar
    The code is
    import java.sql.*; public class dat1 {               public static void main(String[] args)throws SQLException,ClassNotFoundException {         try     {     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");     Class.forName("com.oracle.jdbc.OracleDriver");     } catch (ClassNotFoundException e) { System.out.println("unable to load driver"); return; }     } }
    the error message is
    Error in thread "main" java.lang.NoClassDefFoundError
    Please Help Me
    Thanks For Reading
    Thanks a lot in Advance For your ANSWERS

    maybe if you asked nicely instead of ordering people around we might tell you.
    As it is all you're going to hear is that you don't need both those jars, as they contain different versions of the same driver.
    I'm not going to tell you which you need, as you should have the documentation to tell you that. But then you also should have the documentation to tell you how to set your classpath properly and you failed to read that too.

  • How to connect java to MS Access

    How to connect java to MS Access using jdbc
    Can U write the complete code for it ? How to interact with the fields ?

    G O O G L E
    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2691&lngWId=2
    http://blog.taragana.com/index.php/archive/how-to-access-ms-access-database-from-jdbc/

  • Hi I just got my new Apple TV and I cant figure out how to connect it with My MacBook Air (11-inch, Late 2010- Processor  1.4 GHz Intel Core 2 Duo) OSX Version 10.8

    Hi
    Hi I just got my new Apple TV and I cant figure out how to connect it with My MacBook Air (11-inch, Late 2010- Processor  1.4 GHz Intel Core 2 Duo) OSX Version 10.8

    Are you referring to mirroring or you just unable to set up homesharing.
    AirPlay Mirroring requires a second-generation Apple TV or later, OS X 10.8 or better and is supported on the following Mac models: iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), and MacBook Pro (Early 2011 or newer). It also requires the computer to be using wi-fi.

  • Can' t connect Java with MySQL

    My goal is to connect Java with MySQL. I found many solutions on Internet, but I always get the same mistake:
    SQLException: No suitable driver
    SQLState: 08001
    VendorError: 0MySQL works fine alone or with php.Only thing left me to think is that the installed versions are not compatible for this mysql-connector-java-5.0.4
    I don't believe that could be a reason.
    Installed versions are:
    Apache Tomcat 5.5.20 Server
    Apache HTTP Server 2.2.4
    PHP 5.2.0
    MySQL 5.2
    jre 1.5.0_11
    jdk1.5.0_11
    Apache Tomacat JK2 connector Version: 1.2.20 File Name: mod_jk-apache-2.2.3.so
    mysql-connector-java-5.0.4
    I also set connector in class path: C:\mysql-connector-java-5.0.4;C:\mysql-connector-java-5.0.4\mysql-connector-java-5.0.4-bin.jar;C:\mysql-connector-java-5.0.4\src\com\mysql\jdbc
    For installation I used manulas from:
    http://apacheguide.org/jsp.php
    http://doc.51windows.net/mysql/?url=/MySQL/ch23s03.html
    Here is also a test code in java:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
       public class Connect
           public static void main (String[] args)
               Connection conn = null;
               try {
        conn =
           DriverManager.getConnection("jdbc:mysql://localhost/first_test" +
                                       "user=monty&password=greatsqldb");
        // Do something with the Connection
    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
       }i'm desperate, please help or tell me someone who'll know the answer.
    Thank You in advance

    hey buddy .. it seems yr code is wrong .. in getconnection () method u should also specify the port ,which u r not doing ...
    the default port for MySQL is 3306 ... see below i am giving you a sample code ... its working fine .. and dont forget to put the MySQL driver jar path in to classpath and also copy the jar into common/lib folder of your tomcat ....
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class MySQLConnectionTest {
         public static void main(String[] args) {
    new MySQLConnectionTest().connTest();
    public void connTest() {
              String tableName = "portfolio"; //change as per setting
              String hostName = "10.81.9.39"; // please change for the target database ip or hostname
              String dbPort = "3306"; //change if not using the default
              String dbName = "tradingsystem"; //change as per the given DB name
              String username = "root"; //change as per setting
              String password = "password"; //change as per setting
              System.out.println("before try");
              Double data=0.0;
         Double data1=0.0;
              try {
    Class.forName("org.gjt.mm.mysql.Driver");
                   System.out.println("before driver manager");
    Connection conn = DriverManager.getConnection("jdbc:mysql://"+hostName+":"+dbPort+"/"+dbName, username, password);
    String query1 = "select * from "+tableName+" where User_id='trader1' and Stock_Type='Equity'";
    System.out.println("quesry1="+query1);
    Statement stmt = conn.createStatement();
    ResultSet rs1 = stmt.executeQuery(query1);
    while(rs1.next())
         System.out.println("hiiiiii for rs1");
         System.out.println(rs1);
         Quantity=(Integer)rs1.getObject(5);
         MarketPrice=(Double) rs1.getObject(8);
         data=Quantity*MarketPrice;
         data1+=data;
         System.out.println("data1="+data1);
         i=0;
    rs1.close();
    stmt.close();
    conn.close();
    } catch (ClassNotFoundException e) {
    e.printStackTrace(System.err);
    } catch (SQLException e) {
    e.printStackTrace(System.err);
    i hope it will work for u...
    cheers,

Maybe you are looking for

  • Is anyone else having this problem?

    I can open itunes once but if I close it for any reason I have to shut down my computer and restart it before itunes will open again

  • IWeb 2.0.1 users are in deep trouble. APPLE please don't let us down!!!!!!!

    The new iWeb version has a lot of cool new features. THANKS APPLE But also has a lot of bug's.... but a lot of them I will try to make a list. If you post your findings we can make a big list and sent it to APPLEsomething like "UIUW" "United iWeb Use

  • Exception while using Regular Expressions

    Hi, im using the following regular expression in my code for pattern matching. REGEXP_LIKE(LLT_NAME,''[^[:digit:]^[:alpha:]]'||l_temp_token||'[^[:digit:]^[:alpha:]]|^'||l_temp_token||'[^[:digit:]^[:alpha:]]|[^[:digit:]^[:alpha:]]'||l_temp_token||'$|^

  • Nokia C3-01 broken video file

    Hello! Yesterday I recorded a fun video with my friends and as soon as I stopped recording, an error showed up but I didn't really care because I was talking to my friends. Later that day I wanted to see the video but then instead of having 1 3GP fil

  • Steps to create OO alv

    Hi can any body tell me Steps to create OO alv? regards, dhananjaa