Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Just for those who are going to start programming with Sybase ASE and JAVA, or those who want to test this great RDBMS.

Requirements:

Install a JAVA JDK.

You can use any IDE like Eclipse.

Install Sybase ASE, could be Developer Edition.

Create a project new JAVA Project then copy and paste the following code.

Code example:

package jdbc;
import java.sql.*;
import java.util.*;
public class Jdbc {
public static void main(String[] args) {

  try{
      Class.forName("com.sybase.jdbc4.jdbc.SybDriver");
      } catch (ClassNotFoundException cnfe){
        System.out.println("Could not find the JDBC driver!");
        System.exit(1);
      }
  Connection conn = null;
  try {
      conn = DriverManager.getConnection("jdbc:sybase:Tds:**HOST**:**PORT**/**DATABASE**","**USER**","**PASSWORD**");
      System.out.println("Connection done");
   Statement stmt = conn.createStatement();
   ResultSet rs = stmt.executeQuery( "SELECT * FROM **DATABASE**");
   System.out.println("ID \t Store \t Fecha");
         while ( rs.next( ) ) {
           System.out.println( rs.getString("**COLUMN**")+"\t"+rs.getString("**COLUMN**")+"\t"+rs.getString("**COLUMN**") );
         }
       } catch (SQLException sqle) {
         System.out.println("Could not connect");
         System.exit(1);
        }
}
}
  • SAP Managed Tags:
1 Comment