wood burning stoves
The moose likes Java in General and the fly likes connect to database/ JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "connect to database/ JDBC" Watch "connect to database/ JDBC" New topic

connect to database/ JDBC

Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
I am trying to connect to a sybase database using the JDBC classes, but it is telling me the driver is not found. I have been working on it and can't figure out what the problem is. Here is the code... help please. thanks.
import java.util.*;
import java.sql.*;
public class DataSheetRetriever {

public static void main(String[] args) {
Connection con = null;
String Driver = "com.sybase.jdbc2.jdbc.SybDriver";
String URL = "jdbc:sybase:Tds:";
String Host = "";
String userid = "guest";
String passwd = "guestsun";

try {
con = DriverManager.getConnection(URL+Host, userid, passwd);
Statement select = con.createStatement();
catch(Exception e) {
System.err.println("Unable to load the Sybase Driver " + e.getMessage() );
if(con != null) {
try{ con.close(); }
catch(Exception ee){}

DataSheetRetriever dsr = new DataSheetRetriever();

public Vector getDatasheet(String siteId)
Vector v = new Vector();
return v;
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
hi u need to first download this 'sybase' driver and install it. then u can try running this example.
Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
I agree. Here's the link: http://aspose.com/file-tools
subject: connect to database/ JDBC
It's not a secret anymore!