Trying to connect to Sybase with Java jdbc

Hoping someone can help me to connect to Sybase database (version is Sybase Adaptive Server Enterprise 12.5.3). I am using a technique I read that worked with Access and adapting by some examples for Syabase I found on the web but keep getting errors. Below is my code with some of the examples Ive been using commented out.
I have created a DSN on my Windows Xp o/s named GPTS_SYBASE via ODBC Use DSN set-up wizard, driver is Sybase ASE ODBC Driver.
import java.sql.*;
public class DBConn {
public DBConn(){
public static void main(String[] args) {
try {
//Class.forName("com.sybase.jdbc2.jdbc.SybDriver.class.getname()");
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
String sourceURL = "jdbc.odbc.GPTS_SYBASE";
//String sourceURL = "jdbc.sybase.Tds:GPTSPSYB1:5000/gpts";
Connection conn = DriverManager.getConnection(sourceURL, "gptsdbo", "gptsdbo");
//Connection conn = DriverManager.getConnection(sourceURL);
System.out.println("Success");
} catch (Exception e) {
System.err.println("Got an excpetion! ");
System.err.println(e.getMessage());
Error message from this code is
Got an excpetion!
com.sybase.jdbc2.jdbc.SybDriver

Have you read the Sybase docs or the Java JDBC docs? ODBC != JDBC. They sound the same but are totally different. The DSN is totally irrelevant for type 4 JDBC drivers.
It would help to actually print the stack trace by changing your code to:
catch (Exception e) {
    System.err.println("Got an excpetion! ");
    e.printStackTrace();
}Also, you're mixing the wrong class name with the URL. You need "com.sybase.jdbc2.jdbc.SybDriver" and, in your case jdbc:sybase:Tds:GPTSPSYB1:5000/gpts - note the change to colons, not periods! - when in doubt read the docs!

Similar Messages

  • I have an airport extreme.  i am trying to connect a laptop with windows 7 to a wireless printer, with no luck.  any ideas?

    I have an airport extreme.  i am trying to connect a laptop with windows 7 to a wireless printer, with no luck.  any ideas?

    The problem is not the router.. the issue is the vpn has put your computer in a different IP range with a different gateway. When you turn off the vpn the computer returns to local lan and can print.
    Some vpn software allows you to set gateway to use local net instead of remote gateway or access to other webistes or local lan.
    Read up the issue.
    http://stevejenkins.com/blog/2010/01/using-the-local-default-gateway-with-a-wind ows-vpn-connection/
    Cisco vpn client..
    https://supportforums.cisco.com/thread/239113
    I did not search much.. just grabbed the first article I could find that explains the issue.
    The whole point of the vpn is whilst it is connected your computer is NOT part of the Local Lan .. it is part of the Remote LAN via the vpn tunnel.
    It is also a security risk using split tunnelling so often it will not be allowed.
    Plug the printer directly into the computer via usb or whatever.. Local connection will work.. not local lan.

  • I am trying to connect my iMac with my MacBook What is the command keys and process in doing so. Have firmwre in place.

    I am trying to connect my iMac with my MacBook What is the command keys and process in doing so. Have firmwre in place.

    Here's the Apple Support article on Target Mode http://support.apple.com/kb/HT1661

  • How to connect oracle database with JAVA

    how to connect oracle database with JAVA....
    using j2sdk and Jcreator . which connector to use .. what are the code for that ..

    PLEASE .... Ask in an Oracle Java forum.
    And read the documentaiton. There is a whole document devoted to doing that. http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/toc.htm has examples.
    PLEASE ... do not ask product questions in a forum which clearly has a title saying it is devoted to assisting with download problems.

  • Doubt handling Clob columns with Java JDBC api

    Hi,
    we have a doubt handling Clob columns with Java JDBC api.
    Reading Oracle 10g official documentation (document b10979.pdf, page 236), we found this note:
    ============================================
    To write LOB data, the application must acquire a write lock on the LOB object. One way to accomplish this is through a SELECT FOR UPDATE. Also, disable auto-commit mode.
    ============================================
    We also found a java sample code about how to handle Lob objects at this URL:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
    In our java2 application, we access Clob objects in a quite different
    manner: we use normal setString() and getString() methods, as described into paragraph "Shortcuts For Inserting and Retrieving CLOB Data"
    (document b10979.pdf, page 244).
    Using those methods, we never lock the table row by a SELECT FOR UPDATE statement (as described into the note above). We use simply SELECT, UPDATE and INSERT prepared statement.
    In this way we can insert both clob objects and normal timestamp, number and other types with a single insert statement. Idem for update.
    To recap, our question is:
    Is it mandatory to create a SELECT FOR UPDATE statement when updating clob data? What may be the consequences if we don't use it? It is also correct to insert with a single sql statement both clob and not clob data using the setString() method for the clob types? And more than one lob column in the same record?
    bye,
    luca acri.

    And columns of type FLOAT. These also have, for some unknown reason a metadata type of OTHER, and a type string of 'FLOAT'. Yet PreparedStatement.setNull(x, Types.OTHER) doesn't work and setNull(x, Types.DECIMAL) does.

  • My iPhone 5 keeps on trying to connect the hotspot with wifi not connected. will not allow me to select hotspot at all

    My iPhone 5 keeps on trying to connect the hotspot with wifi not connected. will not allow me to select hotspot at all. can anyone help am in Botswana an no apple store to help?

    I have the same problem, it's better trade my iPhone, or the apple it's gonna fix at the next upgrade? Please, someone help me, I try everything.

  • Trying to connect an iMac with an e-Mac via Linksys

    We are trying to connect my son's eMac with our iMac using a Linksys Wireless-G broadband router on the iMac and a Linksys Wireless G USB adapter for the eMac. We cannot seem to get it going. The router is connected via ethernet to my computer with no problem, we just can't get the eMac side on board. I tried plugging in the same network info from the iMac into my son's computer, but that wouldn't work. Neither computer has an Airport card.
    We really know nothing about networking-zero- and the setup disc is of course only for PCs.
    We really just want to share an internet connection. Is there any tech document out there that can take us through this step-by-step? Did we just buy the wrong stuff? My son is suffering from iTunes withdrawal and I really need some help before my husband starts drilling holes in the wall. Thanks!

    Maria, Welcome to the discussion area!
    Unfortunately you need the proper driver before that USB device will work with your eMac. Because of the need for drivers, USB wireless adapters are notoriously unreliable when used with the Mac OS.
    The best solution is to get the proper wireless card for your eMac. Depending on the model of eMac, it may require the original AirPort card or it may require the AirPort Extreme card.
    Another possibility is a Ethernet wireless adapter. These require no drivers and therefore will work with any Ethernet device. Examples of Ethernet wireless adapters are the Linksys WET11, Linksys WET54G, and the Buffalo Technology WLI-TX4-G54HP bridge.

  • Trying to connect my iPhone6 with my old iMac with 10.6.8 MacOS. It says I need a new version of iTunes. When I try to upgrade the iTunes (11.3.1), it says, it is already the latest version. What do I do now?

    Trying to connect my iPhone6 to my old iMac with 10.6.8 MacOS, and synch up the music. It says I need a new version of iTunes. When I try to upgrade the iTunes on my iMac, it says, it is already the latest version. What do I do now?

    The current version of iTunes is 12.x.x and requires OS X later than Snow Leopard.

  • Error with Connection to Oracle with Wallet , JDBC, and UNIX

    Hello - our application has been getting this error periodically while connecting to an oracle database using OCI JDBC drivers.
    caused by: java.sql.SQLException: ORA-28759: failure to open file
    at oracle.jdbc.driver.DatabaseError.throwsSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:681)
    at oracle.jdbc.driver.T2CConennection.logon(T2CConnection.java :362)
    at oracle.jdbc.driver.PhysicalConnection.<init>
    at oracle.jdbc.driver.T2CConnection.<init>
    at oracle.jdbc.driver.T2CDriverExtension.getConnection
    at oracle.jdbc.driver.OracleDriver.connect
    at java.sql.DriverManager.getConnection
    at java.sql.DriverManager.getConnection
    Once we get this error we keep getting it and are unable to get a connection until we restart it. the file it has the issue with is the cwallet.sso, which I figured out by turning on tracing. The file is there and it gets the connection originally - but for some reason periodically we lose access to that file. But when we get the error the file is there and when we restart the process it's perfectly fine.
    The only way we have been able to replicate this error is by create a sameple JAVA app which just keeps opening connections to the database with the wallet without closing the connections. Everytime we hit the 50th connection that error appears and it's unable to get another connection. If we close the connections everytime it's alright.
    It's not a limit on the amount of connections to oracle because we have no limit set. The best explaination we can find is that unix has some sort of limit on how many concurrent accesses to that file can be done within one process. We have been unable to figure out that limit. We tried playing around with the file descriptor limits to see if it gets more or less then 50, but no luck.
    If anyone has any other suggestions it would be greatly appreciated - we are stuck right now.
    Thanks!

    No suggestions?

  • How to connect microsoft sql with java servlets

    what are steps i should do after writing servlet program to connect with microsoft sql. what coding should i add in web.xml file.if any other steps mention it. i didn't get output or err msg in browser.if i should install jdbc drivers seperately for sql mention it.

    Hi,
    Try to find a DataBase driver for MS SQL ( type 4 which is a pure java) first and put it on the class path i.e under ../lib
    Then in your sevlet, load the DriverManager and from it get a connection to the database as per JDBC spec.
    Regards.
    Alan Mehio
    LONDON, UK

  • I was trying to connect IBM RAD with MSSQL 2000 to generate crystal reports

    After establishing connection through wizard succesfully I try to use the parameters of the connection in .INI file. while establishing normal connection this error msg pops up.
    Failed to open a rowset.
    Details: :SQL Exception: [SQL Error Code] 0 [Error Message:] [IBM] SQL Server JDBC Driver] This driver is locked for use with embedded application.

    Surely the actual error message said "embedded" and not "enbedded"? Copy and paste is better than retyping, please. When I googled that phrase with correct spelling, the only result it returned was this one:
    http://forum.java.sun.com/thread.jspa?threadID=5061573

  • Connect COMTI server with java

    Hi everybody..
    I'm here, because i'm trying to find a way to connect java with a COMTI server.
    If there are any could you give me a simple example of how to do this??
    Thanks in advance.

    Do you have any example, please.. I'm a newbe on this and do not know how to do it :)

  • Connect staroffice8 database with java

    Hi,
    I m developing a reporting tool where i would have to connect to a staroffice 8 database (star base). The database has .odb extension. The reporting tool will run on a solaris network. I tried searhcing for JDBC driver to connect the staroffice database.
    please help!!
    regards,
    kunal

    i dont think it uses adabase .. and also i checked the entire google and the sun site .. but could not find any information ..also staroffice provides with a driver com.sun.star.comp.sdbc.JDBCDriver .. but i m not sure if its the right one to use ..
    regards,
    kunal parmar

  • Need help for connecting Ms Acces with java Swing in Mac OS

    Hi all,
    i need to connect to Ms Access in MAc os through my java swing program.
    Is it possible for accessing Ms access through dsn in Mac OS.
    If Possible which driver shall i use for Establishing Connection with MS Access in Mac OS.
    Suggestion is needed urgently.
    Can anybody help me out regarding this..
    Thanks in advance.
    Regards,
    sreand

    if I don't find a better solution I'll try your 2nd option but what do you mean by "combo" update?
    My understanding is to simply insert the OS 10.5 installation CD, reinstall the OS and the just keep updating it via the OS SSoftware update panel and stop untill I see the scary Java 8 update. Is that what you meant?
    While you can do it that way, the combo update picks up operating system updates through a collection of releases. When dealing with operating system upgrades, I've found using the combo updates to be more reliable than Software Update, as sometimes Software Update doesn't apply updates correctly, and weird things can happen. Doesn't happen often though, thankfully.
    So the OS X 10.5.5 Combo update contains all updates between 10.5.0 and 10.5. The 10.5.8 combo update contains the updates from 10.5 thru 10.8. Here are the updates:
    10.5 combo update: http://support.apple.com/kb/DL692
    10.8 combo update: http://support.apple.com/kb/DL866
    If you go down the combo path, repair permissions before and after doing each update. Then do Software Update for any other non-OS X updates, and don't apply the Java Update 8.

  • Connection error -2147217387 with Java RAS SDK and Crystal Server 2011

    Due to a change in operating system, we are required to upgrade our Crystal Reports server from BusinessObjects Crystal Reports Server 11.5 to SAP Crystal Server 2011. We use the Java RAS SDK (RASCore 9.2.2.446 / RASApp 9.0) more or less as described in Java RAS2008-unmanaged exportreport. We use the Crystal Server to export reports stored on disk as PDF files.
    In SAP Crystal Server 2011, the CrystalReports2011ReportApplicationServer is configured with Request Port 1566 and Host Identifier 172.16.4.154 (the local machine). The Crystal Server, report-definition files, and Java VM are all on the same machine.
    The error is
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: XML serialization failed.---- Error code:-2147217387 Error code name:connectServer
         at com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException.throwReportSDKServerException(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.v.request(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.ab.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportAppSession.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportAppSession.do(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportAppSession.initialize(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ClientDocument.for(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.for(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ClientDocument.open(Unknown Source)
         at ourpackage.OurClass.openReport(OurClass.java:95)
         ... 6 more
    Caused by: java.net.SocketException: Connection reset
         at java.net.SocketInputStream.read(SocketInputStream.java:189)
         at java.net.SocketInputStream.read(SocketInputStream.java:121)
         at java.net.SocketInputStream.read(SocketInputStream.java:203)
         at java.io.DataInputStream.readInt(DataInputStream.java:388)
    The code is as follows.
    ReportClientDocument clientDocument = new ReportClientDocument();
    clientDocument.setReportAppServer("172.16.4.154:1566"); // localhost
    // Error occurs on ReportClientDocument.open method
    clientDocument.open("D:\\path\\to\\report.rpt", com.crystaldecisions.sdk.occa.report.application.OpenReportOptions.refreshRepositoryObjects.value());
    DatabaseController dbController = clientDocument.getDatabaseController();
    dbController.logon("dbuser", "dbpassword");
    ParameterFieldController pfController = clientDocument.getDataDefController().getParameterFieldController();
    Fields fields = clientDocument.getDataDefinition().getParameterFields();
    ParameterField oldParameter = (ParameterField) field.get(0);
    ParameterField newParameter = new ParameterField();
    oldParameter.copyTo(newParameter, false);
    newParameter.getCurrentValues().clear();
    ParameterFieldDiscreteValue newDiscreteValue = new ParameterFieldDiscreteValue();
    newDiscreteValue.setValue("paramValue");
    newParameter.getCurrentValues().add(0, newDiscreteValue);
    pfController.modify(oldParameter, newParameter);
    clientDocument.refreshReportDocument();
    PrintOutputController po = clientDocument.getPrintOutputController();
    InputStream is = po.export(reportFormat);
    Could anyone advise me how to proceed with resolving this error?

    Thanks for the link. I copied the CrystalReportsSDK.jar and logging.jar from the Crystal Server java\lib directory into my project and revised the code accordingly. Now, a slightly different error occurs at the same place:
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: Unable to connect to the server: {0}. --- Connection reset by peer: socket write error---- Error code:-2147217387 [CRSDK00000039] Error code name:connectServer
      at com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException.throwReportSDKServerException(ReportSDKServerException.java:115)
      at com.crystaldecisions.proxy.remoteagent.TCPIPCommunicationAdapter.request(TCPIPCommunicationAdapter.java:659)
      at com.crystaldecisions.proxy.remoteagent.AdapterCommunicationChannel.send(AdapterCommunicationChannel.java:88)
      at com.crystaldecisions.sdk.occa.report.application.ReportAppSession.request(ReportAppSession.java:382)
      at com.crystaldecisions.sdk.occa.report.application.ReportAppSession.logon(ReportAppSession.java:342)
      at com.crystaldecisions.sdk.occa.report.application.ReportAppSession.initialize(ReportAppSession.java:330)
      at com.crystaldecisions.sdk.occa.report.application.ClientDocument.initializeServerConnectionAdapter(ClientDocument.java:627)
      at com.crystaldecisions.sdk.occa.report.application.ClientDocument.initializeServerConnection(ClientDocument.java:658)
      at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.initializeServerConnection(ReportClientDocument.java:1420)
      at com.crystaldecisions.sdk.occa.report.application.ClientDocument.open(ClientDocument.java:982)
      at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.open(ReportClientDocument.java:226)
      at ourPackage.OurClass.openReport(OurClass.java:97)
    The revised code is
    ReportClientDocument clientDocument = new ReportClientDocument();
    clientDocument.setReportAppServer("172.16.4.154:1566"); // localhost
    // Error occurs here
    clientDocument.open("D:\\path\\to\\report.rpt", com.crystaldecisions.sdk.occa.report.application.OpenReportOptions.openAsReadOnly.value());

Maybe you are looking for

  • Error while sending data to supplier

    Hi All, We are facing the errors while sending transaction to our supplier.Actually we send 60 transactions to our supplier in which 15 are errored out in B2B with the below error. Please help me in resolving this. 2010.06.09 at 16:40:04:876: Thread-

  • Can i replace mac mini hard drive?

    Mac Mini is running slow. Tried all I know what to do. Can I replace the hardrive for this unit that is an "09" I think? I am running 10.6.8. Thanks

  • Subtitles in iTunes 11.

    I have a movie file that has subtitles in multiple languages, however, when played in iTunes 11, only one option is available.  How do I enable the other subtitle tracks?

  • Adobe X Pro-different background when I add pages

    When I add pages to a pdf document the color and the background of the text changes from the original. All the pages that I add contain images and text with web link. I have tried to modify following the help guide but I could not change background a

  • MV45AFZZ USEREXIT_SAVE_DOCUMENT Change VBEP-ETTYP Value

    Greetings,    In VA01/VA02, credit check processing seems to occur after userexit_save_document_prepare leaving me only with userexit_save_document. In userexit_save_document, I am trying to change the schedule line category depending on VBUK-CMGST v