netbeans IDE 7.0中的错误,不能非连接到databse(sql server2005) [英] error in netbeans IDE 7.0 ,can not nonnected to databse(sql server2005)

查看:170
本文介绍了netbeans IDE 7.0中的错误,不能非连接到databse(sql server2005)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Win 7 64bit和sql server 2005中使用netbeans 7.0 64bit
而且我无法连接到数据库

I work with netbeans 7.0 64bit in win 7 64bit and sql server 2005
and i can not connected to database

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

推荐答案

问题可能出在连接字符串或配置上.

查看是否有这些帮助:
ODBC驱动程序管理器–找不到数据源名称,也未指定默认驱动程序 [ [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,未指定默认驱动程序 [
The issue can be with connection string or the configuration.

See if these help:
ODBC Driver Manager – Data source name not found and no default driver specified[^]
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified[^]


这篇关于netbeans IDE 7.0中的错误,不能非连接到databse(sql server2005)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆