Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

How to link SQL SERVER with JAVA?

I'm doing a cafe management system.I would like to know how to like SQL Server with Java.Hope to hear from you soon.I need it urgently.I would also like to know where i can see some Java typical systems as the one i'm doing.Please help me.Thanks
0
Alisha23
Asked:
Alisha23
1 Solution
 
mocartsCommented:
you can use generic ODBC connection:

import java.sql.*;
import java.util.*;

public class CounterData {
  private Connection con = null;

  public CounterData() { }
 
  public CounterData(String DatabaseName) {
    Connect(DatabaseName);
  }

  public boolean Connect(String DatabaseName) {
    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch (Exception e) {
      System.out.println("Failed to load JDBC/ODBC driver.");
      return false;
    }
    try {
      con = DriverManager.getConnection("jdbc:odbc:"+DatabaseName);
    } catch (Exception e) {
      System.out.println(e);
      return false;
    }
    return isConnected();
  }
  public void Disconnect() {
    try {
      if (con != null) con.close();
    } catch (SQLException e) {}
  }
}

wbr, mo.
0
 
prasannaaCommented:
If you r using SQL Server 2000
Instead of using JDBC ODBC Bridge u can download the Microsoft SQL Server 2000 Driver for JDBC from microsoft web site and you can use the driver
And u can use the help

Cheers
prasannaa
0
 
CleanupPingCommented:
Alisha23:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now