There are two parts to this question.
I have been trying to install and test SQL Anywhere Sybase connection using an existing project in Eclipse. I did the following:
Installed SQL Anywhere 17
Navigated to the SQL Anywhere 17 Java folder and used the following command to install
sajdbc4.jar
:mvn install:install-file -Dfile=<path/to/sajdbc4.jar> -DgroupId=com.sqlanywhere -DartifactId=sajdbc4 -Dversion=17.0.0 -Dpackaging=jar
Added the following POM dependency:
<dependency> <groupId>com.sqlanywhere</groupId> <artifactId>sajdbc4</artifactId> <version>17.0.0</version> </dependency>
Tried importing:
com.sqlanywhere.jdbc4.sqlanywhere.SQLAnywhereDriver
But It gave me a "Cannot be resolved" error
Tried
mvn clean install
, it didn't work.
This is my code:
public Map<String,String> getServiceStatuses() throws Exception {
var obj = new HashMap<String,String>();
obj.put("status","success");
Connection conn = null;
Statement stmt = null;
try{
//STEP 2: Register JDBC driver
Class.forName("com.sqlanywhere.jdbc4.sqlanywhere");
//STEP 3: Open a connection
System.out.println("Connecting to database...");
DriverManager.setLoginTimeout(10);
conn = DriverManager.getConnection("jdbc:sqlanywhere:uid=abc;pwd=def;eng=xyz");
if(conn.isClosed()) {
System.out.println("This is closed");
} else {
System.out.println("This is open");
}
} catch(Exception e) {
e.printStackTrace();
}
return obj;
}
Now using this code I haven't been able to test a SQL Anywhere Sybase driver yet, which brings me to my second question.
When I installed SQL Anywhere 17, Sybase Central, which is required to setup a Sybase SQL Anywhere server in my local didn't get installed. I tried installing SQL Anywhere 17 in a different machine and it still wouldn't install Sybase Central. I downloaded the trial version by logging in to their website. I installed the developer version. I uninstalled and reinstalled and "Custom" this time which still didn't show the Sybase Central option. I couldn't find anything helpful online pertaining to this
Sorry about the horrible formatting, if someone can help me with this it would be great. I am not sure if I installed sajdbc4 within the local mvn repo the right way and I have no way of testing this since I couldn't install Sybase Central.