title: Connecting to sybase using jdbc in solaris
body: <p>I am trying to learn how to use jdbc.
  Normally to connect to sybase db on solaris I use:</p>
  
  <pre><code>isql -Usa -Pxxxxxx -Dxxxxxx
  </code></pre>
  
  <p>its gets connected to the db by the above.and i can rightaway execute the queries.</p>
  
  <p>Now i am trying to just do a similar thing using java.</p>
  
  <p>below is my code.</p>
  
  <pre><code>public class SKRSample
  {
    public static void main(String args[])
    {
      try
        {
          Class.forName("com.sybase.jdbc.SybDriver");
        }
      catch (ClassNotFoundException cnfe)
        {
        System.err.println("Error loading driver: " + cnfe);
        }
      try
        {
         String host = "172.16.65.33";
         String dbName = "bsmdb";
         int port = 1234;
         String url = "jdbc:sybase:Tds:" + host + ":" + port + ":" + "?SERVICENAME=" + dbName;
  
          for (int n = 0; n&lt;args.length; n++) {
           if (args[n].equals("-u")) user = args[++n];
           else if (args[n].equals("-p")) password = args[++n];
           else throw new IllegalArgumentException("Unknown argument.");
          }
          Connection con = DriverManager.getConnection(url, user, password);//here is the error.
  </code></pre>
  
  <p>The last line of the code is where there is a runtime error.</p>
  
  <p>i compiled the code and execueted as below:</p>
  
  <pre><code>setenv LOGIN "sa"
  setenv PASSWORD "xxxxxxx"
  javac SKRSample.java
  java SKRSample -u $LOGIN -p $PASSWORD
  </code></pre>
  
  <p>the error i am getting is :</p>
  
  <pre><code>Unexpected exception : java.sql.SQLException: No suitable driver found for jdbc:sybase:Tds:172.16.65.33:1234:?SERVICENAME=bsmdb, sqlstate = 08001
  </code></pre>
  
  <p>i have a doubt that either the host is incorrect or the port is incorrect or the url i am framing is incorrect.how can get the host name if at all it is incorrect.and also how can get the port number if the problem lies there.
  But i am not sure about the problem.Can anyone give me some head's up regarding where exactly the problem is there.</p>