facebook

JDBC code fails but runs in Eclipse Helios

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #315006 Reply

    Alejandro Barrero
    Participant

    I know this is not a J2EE question, but I could not find an appropriate forum. The code is:

    
        public static void main(String[] args) {
            try {
                DataSource dataSource = new AccessDataSource(
                        "D:\MyWorkspaces\Eclipse\The Paperless Office\PaperlessOffice.database",
                        1);
                Connection conn = dataSource.getConnection();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    
        public Connection getConnection() throws SQLException {
            String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
            String fullConnectionString = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="
                    + filePath;
            Connection conn = null;
            try {
                Class.forName(driver);
                conn = DriverManager.getConnection(fullConnectionString, userName,
                        password);
            } catch (ClassNotFoundException cnfe) {
                throw new SQLException("ClassNotFoundException");
            } catch (SQLException e) {
                throw new SQLException("SQLException");
            }
    

    I have in both the same Java compliance, 1.6, and the same jre “C:\Program Files (x86)\Java\jdk1.6.0_20”.

    #315007 Reply

    Alejandro Barrero
    Participant

    Sorry. I found that the code that runs in Eclipse is in another project. The code in the same project also fails. I DON’T KNOW HOW TO DELETE THIS POST.

    #315008 Reply

    Alejandro Barrero
    Participant

    I need this post to go on. The actual problem is that in MyEclipse, the code runs well in one workspace but fails in another.

    #315012 Reply

    support-swapna
    Moderator

    handro1104,

    Can you please answer some questions for me to understand the issue?

    1) Please share your installation details from MyEclipse > Installation Summary > Installation Details. Paste them here for me.

    2) What is the error you see in the workspace in which the code is not working. Clear the error log which is located at < workspace dir>/.metadata/.log . Now switch to the workspace where your code is not working. Run it and check the .log file for any errors of interest. Paste them here for me.

    #315019 Reply

    Alejandro Barrero
    Participant

    Thank you again for your support. I actually realized that the problem is with Eclipse because the problem also occurs with the same workspace. On the other hand, I solved the problem by by copying the code to a new workspace (haven’t tried with a new project in the same workspace.).

    #315058 Reply

    support-swapna
    Moderator

    handro1104,

    Glad that it is working fine.
    Do let us know if you have any other issues.

    #315065 Reply

    Alejandro Barrero
    Participant

    Hi swapna. I hope you remember my problem creating web applications with only a servlet.

    #315135 Reply

    support-swapna
    Moderator
Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: JDBC code fails but runs in Eclipse Helios

You must be logged in to post in the forum log in