Results 1 to 2 of 2
  1. #1
    Ludson27 is offline Member
    Join Date
    Dec 2008
    Rep Power

    Default Problem conecting to SQL Server 2008

    Hi, I'm trying to conect to a database in SQL Server 2008 but I'm having some problems. Here is my code and the error I got.

    import java.sql.*;
    public class Main {

    public static void main(String args[]) {
    System.out.println("Testing access to SQLServer\n\n");
    Connection conn = null;
    String teste = "SELECT Name, Adress FROM TB_Cliente;";

    try {
    conn = DriverManager.getConnection("jdbc: odbc: DSK_RENATO", "sa", "mope2008");
    Statement stm = conn.createStatement();
    ResultSet rs = stm.executeQuery(test);
    while ( {
    String Nome = rs.getString("Name");
    String Endereco = rs.getString("Adress");
    System.out.println("Name: " +Name+ " Adress: " + Adress);
    } catch(ClassNotFoundException e) {
    System.out.println("excessão Class not found");
    } catch(SQLException e) {
    System.out.println("SQL Exception... Error in querry:");
    } finally {
    try {
    System.out.println("\n\nClosing the conection");
    } catch(SQLException erro) {
    System.out.println("Error in closing");

    Testing access to SQLServer

    SQL Exception... Erro na consulta:
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source names not found and none standart driver specified
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknow n Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at Main.main(
    Exception in thread "main" java.lang.NullPointerException
    at Main.main(


  2. #2
    joeyxaza is offline Member
    Join Date
    Jan 2009
    Rep Power

    Smile problem connecting to sql server 2008

    according to your error "java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source names not found and none standart driver specified"

    it means that you have not yet created a datasource for your database connection. if you are using XP, u can create a datasource by going to
    control panel -> administrative tools -> datasources . create a new datasource under the user dsn named dsk_renato, using sql server as your datasource, fill in the other requirements according to ur sql server details and rerun ur java code

Similar Threads

  1. Problem connect to SQL Server
    By Crisanto in forum Eclipse
    Replies: 1
    Last Post: 12-02-2008, 01:13 AM
  2. Problem in Starting JBOSS Server
    By 82rathi.angara in forum Networking
    Replies: 0
    Last Post: 06-16-2008, 03:58 PM
  3. Replies: 4
    Last Post: 05-21-2008, 07:55 AM
  4. Sql server connection problem
    By tanvirtonu in forum JDBC
    Replies: 1
    Last Post: 03-31-2008, 01:46 PM
  5. client-server communication problem
    By revathi17 in forum New To Java
    Replies: 1
    Last Post: 08-09-2007, 03:21 PM

Posting Permissions

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