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);
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 |