Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I work with netbeans 7.0 64bit in win 7 64bit and sql server 2005
and i can not connected to database

Java
import java.sql.*;

public class JavaApplication4 {

    /**
     * @param args the command line arguments
     */
    private static Connection link;
    
    public static void main(String[] args) {
try 
            {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                link = DriverManager.getConnection("jdbc:odbc: asd ","","");
                
                System.out.println("Connected to database");
            }
                catch(ClassNotFoundException cnfEx) 
                {
                    System.out.println("* Unable to load driver! *");
                    System.exit(1);
                }
                catch(SQLException sqlEx) 
                {
                    System.out.println("* Cannot connect to database! *");
                   System.out.println(sqlEx.getMessage());
                    System.exit(1);
                }

            try 
            {
                link.close();
                System.out.println("Disconnected to database");
            }
                catch(SQLException sqlEx) 
                {
                    System.out.println("* Unable to disconnect! *");
                    System.exit(1);
                }
         }
   }



error:
* Cannot connect to database! *
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Posted
Updated 13-May-12 0:14am
v3

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900