How  to access database in Sql Server 7.0 using Java

I am trying to access a database in SQL Server 7.0 using JDBC.But it is giving me errors.I have used following statements to connect the database
private String URL = "jdbc:odbc:DatabaseName";
private String userName="user";
private String passWord="password";
Class.forName( "sun.jdbc.odbc.SQLServerDriver" );
connection = DriverManager.getConnection( URL,userName,"passWord" );
where "username" and "password" are user Name and password respectively to access the database in SQL Server 7.0.

I am sorry but I have written like;
private String URL = "jdbc:odbc:DatabaseName";
private String userName="user";
private String passWord="password";
Class.forName( "sun.jdbc.odbc.jdbcOdbcDriver" );
connection = DriverManager.getConnection( URL,userName,"passWord" );
where "username" and "password" are user Name and password respectively to access the database in SQL Server 7.0. And I have used the same name in "ODBC data source" as that of the database.I am trying some examples from book and these examples just work fine with MS Access( I created those databases in Access and tried the examples) but not with SQL Server 7.0. Do I need a separate driver or something?

Similar Messages

  • Linked Server to Access Database in SQL Server 2012 is working perfectly.But, All of sudden it is showing SQL Error Code:7303

    Linked Server to Access Database in SQL Server 2012 is working perfectly.But, All of sudden it is showing SQL Error Code:7303  
    Unable to connect to the database type that is created with earlier versions type. But the same Linked Server in another SQL Server instance is working perfectly. I am unable to rectify what is the problem please help.

    All of sudden it is showing SQL Error Code:7303  
    Error 7303 = "Cannot initialize the data source object of OLE DB provider "%ls" for linked server "%ls"."?
    Check the data Provider on the machine, e.g. using ODBC Admin by creating a DSN
    Olaf Helper
    Hi Olaf Helper,
    I don't now how to add a DSN for the Access Database using ODBC Admin. Can you Please help me with that one. as the solution to above problem i Have added a startup parameter -g512 to SQL Server is it effects my existing Assemblies in SQL Server. I am replacing
    the startup parameter as -g500 to -g512 here.
    Thank you
    Regards,
    AyubKhan M

  • Issues in Importing Access Database into SQL Server 2014 Express

    I have been trying to import the Northwind.accdb database into SQL Server 2014 Express using the SQL Server Import and Export Wizard. Every time I try, I end up with the following messages. I have reviewed previous replies given to similar queries but
    I am not getting anywhere. Appreciate if anyone can help. Thanks.
    Error 0xc0202009: Source - Customers [1]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E37.
     (SQL Server Import and Export Wizard)
    Error 0xc02020e8: Source - Customers [1]: Opening a rowset for "`Customers`" failed. Check that the object exists in the database.
     (SQL Server Import and Export Wizard)
    Exception from HRESULT: 0xC02020E8 (Microsoft.SqlServer.DTSPipelineWrap)

    Tried that. It doesn't support SQL Server 2014. Tried using SQL Server 2012. Ended with following error:
    First I got this message:
    You are connecting to SQL Server version that is different the version specified in the SSMA project. This may lead to schema not converted correctly and synchronisation issues. Do you want to continue?
    I replied with 'Yes' and that ended with the following error.
    Connection to SQL Server established successfully.
    Connection string: Server=VPCL12S1E\SQLEXPRESS2014;Trusted_Connection=TRUE;Encrypt=FALSE;TrustServerCertificate=FALSE;Application Name=SSMA for Access;Pooling=False;
    Error collecting data. See the inner exception for details.

  • How to compare 2 dates in SQL Server 2000 DB using Java?

    How do you compare 2 dates in SQL Server 2000 DB using Java?
    Let's say we have two fields: Date Reported and Target Finish Date.
    Date Reported is 09-10-2004 09:55:55: PM
    Target Finish Date is 09-12-2004 11:59:59: PM
    What i want to happen is i want to convert both dates to days and get the difference of the two.
    can SQL Server 2000 DB do this?

    it doesnt wrk.
    ok here's what i did:
    iv tested a simple code for this case.
    I created a table name tblDate which has 3 columns namely date_ID, date_From (datatype datetime), date_To (datatype datetime).
    I inserted 1 row: date_ID has the value 1, date_From has the value 10/22/2004, and date_To has the value 10/24/2004.
    i run the java code below:
    int days = 0;
              String query = "SELECT date_From, date_To cast(date_From-date_To AS int) AS Diff FROM tblZoo WHERE date_ID = '1'";
              try
                   DBConnect db = new DBConnect();
                   db.openCon();
                   ResultSet rs = db.execute(query);
                   while(rs.next())
                        days = rs.getInt("Diff");
                   db.closeCon();                         
              catch (Exception ex)
                   System.out.println("Error on Execution: " + ex);
              return days;___________
    an error occurred: Error on Execution: java.lang.nullpointerexception

  • How to attach database in sql server 2005 restricted mode

    hi i have a database i want once i have attach database in sql server 2005, anyone cannot do detach, script and delete my database except myself. I mean i want to secure my database to avoid unauthorized persons access
    how it is possible in sql server 2005 express management studio

    There are restrictions for normal Logins but a administrator in SQL server can always detach,script and delete your database.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • How to connect to a Sql server from Oracle using db link

    Hi All,
    Does anybody have any idea about how to connect to a sql server from oracle database using db link to syncronize the data? I need to pull the data from Sql server table to Oracle tables and relay messages back to the sql server.
    Thank you,
    Praveen.

    we have 2 products - DG4MSQL and DG4ODBC.
    DG4ODBC is for free and requires a 3rd party ODBC driver and it can connect to any 3rd party database as long as you use a suitable ODBC driver
    DG4MSQL is more powerfull as it is designed for MS SQL Server databases and it supports many functions it can directly map to SQL Server equivalents - it can also call remote procedures or participtae in distributed transactions. Please be aware DG4MSQL requires a license - it is not for free.
    Check out Metalink and you'll find notes how to configure both products.
    For a generic overview:
    Note.233876.1 Options for Connecting to Foreign Data Stores and Non-Oracle Databases
    And the setup notes:
    DG4ODBC
    Note.561033.1 How to Setup DG4ODBC on 64bit Unix OS (Linux, Solaris, AIX, HP-UX) :
    Note.466225.1 How to Setup DG4ODBC (Oracle Database Gateway for ODBC) on Windows 32bit RDBMS.HS-3-2 :
    Note.109730.1 How to setup generic connectivity (HSODBC) for 32 bit Windows (Windows NT, Windows 2000, Windows XP, Windows 2003) V817:
    Note.466228.1 How to Setup DG4ODBC on Linux x86 32bit
    DG4MSQL
    Note.466267.1 How to Setup DG4MSQL (Database Gateway for MS SQL Server) on Windows 32bit
    Note.562509.1 How to Setup DG4MSQL (Oracle Database Gateway for MS SQL Server) 64bit Unix OS (Linux, Solaris, AIX,HP-UX)
    Note.437374.1 How to Setup DG4MSQL (Oracle Database Gateway for MS SQL Server) Release 11 on Linux

  • Move Access database to SQL Server

    We have a database that was built and managed in Access. The database has grown too large for Access and I have been asked to move it on to our Windows Server 2012 box that runs SQL Server 2012. What is the best way to make the conversion?
    This topic first appeared in the Spiceworks Community

    see
    http://support.microsoft.com/kb/237980/en-us
    http://technet.microsoft.com/en-us/library/hh313039.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Copy the data from Sql Server to edirectory using java

    Hi ,
    I am new to e directory.I don't know how it works.Can some one assist
    me on this ,I have to extract data from SQL Server and update these
    data in edirectory.This is needs to be done using java.
    If any one can provide me the sample code or please suggest how to
    proceed .
    Thanks in advance
    dukewarm
    dukewarm's Profile: http://forums.novell.com/member.php?userid=53430
    View this thread: http://forums.novell.com/showthread.php?t=373051

    dukewarm;1792481 Wrote:
    > Hi ,
    >
    > I am new to e directory.I don't know how it works.Can some one assist
    > me on this ,I have to extract data from SQL Server and update these
    > data in edirectory.This is needs to be done using java.
    >
    > If any one can provide me the sample code or please suggest how to
    > proceed .
    >
    > Thanks in advance
    Read the values from SQL server and use LDAP to update the data in
    eDirectory.
    Thomas
    thsundel
    thsundel's Profile: http://forums.novell.com/member.php?userid=128
    View this thread: http://forums.novell.com/showthread.php?t=373051

  • How to access  database connection from datatsource in a standalone java ap

    My java standalone application wants connection to database with lookup to datasource name which is configured in the oc4j app server.
    Please guide me with some ideas to acheieve this.

    user510497,
    Following sample program requires access to classes in "oc4j.jar" file.
    Test environment:
    * Server:
    + OC4J stand-alone 10.1.2.0.2
    + Red Hat Enterprise Linux AS release 3
    + Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    + Oracle Database 10g Release 10.1.0.4.0 - 64bit Production
    * Client
    + Microsoft Windows XP Professional Version 2002 Service Pack 2
    + Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    import java.sql.SQLException;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    public class DataSrc2 {
      public static void main(String[] args) {
        Connection conn = null;
        Properties l_props = new Properties();
        l_props.put(Context.INITIAL_CONTEXT_FACTORY,
                    "com.evermind.server.rmi.RMIInitialContextFactory");
        l_props.put(Context.PROVIDER_URL, "ormi://your_OC4J_host/");
        l_props.put(Context.SECURITY_PRINCIPAL, "your_OC4J_user");
        l_props.put(Context.SECURITY_CREDENTIALS, "your_OC4J_password");
        Context l_jndiContext = null;
        try {
          l_jndiContext = new InitialContext(l_props);
          Object l_obj = l_jndiContext.lookup("default-data-source");
          DataSource ds = (DataSource) l_obj;
          conn = ds.getConnection("scott","tiger");
          DatabaseMetaData dbmd = conn.getMetaData();
          System.out.println(dbmd.getDatabaseProductVersion());
        catch (NamingException x_naming) {
          x_naming.printStackTrace();
        catch (SQLException xSql) {
          xSql.printStackTrace();
        finally {
          if (l_jndiContext != null) {
            try {
              l_jndiContext.close();
            catch (NamingException x_naming) {
              System.err.println("Failed to close JNDI context.");
              x_naming.printStackTrace();
          if (conn != null) {
            try {
              conn.close();
            catch (SQLException xSql) {
              System.err.println("Failed to close [database] connection.");
              xSql.printStackTrace();
    }NOTES:
    1. Datasource lookup name is value of "default-data-source" attribute of "orion-application" element in file:
    <OC4J_HOME>/j2ee/home/config/application.xmlGood Luck,
    Avi.

  • How to connect to a specific database in SQL server

    Hi,
    How can I connect to a specific database in SQL server? I used the following statement. But my table is inserted to the 'master' database in the SQL server. How can I insert my tables to the specific database tahta I have created before?
    Connection con;
    String sURL = "jdbc:microsoft:sqlserver://SERVER_NAME:1433";
    con = DriverManager.getConnection ( sURL, sUsername, sPassword);

    Hi,
    When I use the syntax:
    String sURL = "jdbc:microsoft:sqlserver://SERVER_NAME:1433/DATABASE_NAME;selectMethod=cursor";
    it gives an error as follows:
    problems connecting to jdbc:microsoft:sqlserver://SERVER_NAME:1433/DATABASE_NAME;selectMethod=cursor:
    [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.
    What is the way to connect to a specific database?

  • How to connect external database(Ex:SQL Server/Tivoli)  from ABAP Webdynpro

    Hi,
    Any one have idea how to connect external database like SQL Server/Tivoli to access tables from WebDynPro ABAP.
    Please point to me some links if you have
    Thanks
    Praveen

    Hi,
    Please check out this link -
    FETCH DATA FROM ORACLE DATABASE USING Web Dynpro
    Regards,
    Lekha.

  • Access vs. SQL Server for online database

    I have a client who insisted on using Access for his online
    database because he wanted to be able to download it quickly and
    easily to be able to manipulate data on his end. However, after
    importing about 20 thousand records into his existing database,
    he's not happy with the speed at which it's now processing searches
    - the search criteria and underlying queries are very complicated
    to begin with. We had the SQL Server discussion previously, but he
    wanted to keep it in Access. So, my question is...how much faster
    can SQL Server process data over Microsoft Access? Will the results
    be significant enough to justify converting the database to SQL
    Server? Would his data process faster if he was on a dedicated
    server instead of a shared server? Thanks!

    If you can get away with using 3 digit zip code areas for
    some of your partners, that might cut down on the total number of
    records in your database. Also, in addition to indexing, indexing,
    indexing, be aware that the "distinct" keyword is a pretty big
    resource hog as well. Might be best to stay away from that one.
    Not sure if I remember if Access supports stored procedures
    or not, but any queries that you can precompile on the database
    side will speed things up a bit.
    Of course, you could just explain to him that downloading a
    20,000 record access file, waiting for it to finish, editing it,
    uploading it back to the server, and waiting for it to finish is
    not exactly a very effective work flow. You could switch everything
    over to MS SQL and then just give him a bound data grid into the
    data in CF if he really wants to manipulate the records like that.
    But then again, I know how these things go. My
    condolences.

  • How to restore SQL Server 2008 database to SQL Server Express 2012

    How to restore SQL Server 2008 database to SQL Server Express 2012.
    I BACKED UP a SQL Server 2008 database from work, which runs the enterprise version of 2008, and I tried to RESTORE it to my new 64-Bit home PC which is running the new SQL Server Express 2012 64-Bit (Advanced Edition).
    But if fails. I get the following message text.
    Can anyone help me please. I thought restoring a 2008 database to the later version 2012 would be possible.
    Here is the error message. Thanks.
    TITLE: Microsoft SQL Server Management Studio
    Restore of database failed. (Microsoft.SqlServer.Management.RelationalEngineTasks)
    ADDITIONAL INFORMATION:
    System.Data.SqlClient.SqlError: The database was backed up on a server running version 8.00.2039. That version is incompatible with this server, which is running version 11.00.3128. Either restore the database on a server that supports the backup, or use a
    backup that is compatible with this server. (Microsoft.SqlServer.SmoExtended)

    ADDITIONAL INFORMATION:
    System.Data.SqlClient.SqlError: The database was backed up on a server running version 8.00.2039. That version is incompatible with this server, which is running version 11.00.3128. Either restore the database on a server that supports the
    backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.SmoExtended)
    Are you sure your database is SQL server 2008 from error message it seems your SQL server version is 2000.I guess you have multiple versions of SQL server.
    AFAIK you cannot restore backup of SQL server 2000 to 2012 directly .Restore it first to SQL 2008/2008R2 or 2005 then take backup again of new database created and then you would be able to restore it on 2012.Its kind of intermediate way
    Also make sure your DB size is less than 10 G as max DB size supported by Express edition is 10 G and if your DB size is more than 10 G restore will fail.
    You are also trying to restore enterprise DB backup on express edition so you will loose enterprise features on express edition
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • How to connect captivate file in a database (MS SQL SERVER 2008)

    Hi...
    How to connect captivate file in a database (MS SQL SERVER 2008) ???
    Kindly response please..
    thanks!!!

    Hi there
    See if the link below helps you out.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • How to create a database in Sql server management studio

    how to create a database in Sql server management studio

    One method is to run the SQL statement below from a SSMS query window:
    CREATE DATABASE MyDatabase;
    You can also right-click on the Databases node in SSMS Object explorer and select New Database.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

Maybe you are looking for

  • MS Access VB and RFC

    Hello, Every Time i try to 'Create a Server object and Setup the connection' Set R3 = CreateObject("SAP.Functions") MS Access prompts a 'Automatisierungsfehler (Fehler 440)' 'Das angegebene Modul wurde nicht gefunden.' 'Error 440' 'The given modul wa

  • How to cancel one file from recycle bin ...

    Hi all, most probably I'm making a very stupid question but how I can remove just selected files from recycle bin ? For removing I mean DELETED the files and not returning them into their original position. Thanks in advance for your help here Ciao G

  • 1080p30 .mov files from canon eos 5DMarkII in Final cut express 4.0.1

    Hi everybody. i need some help to import HD vidéo .mov files from Canon Eos 5DMarkII in final cut express. The files is in 1080p30 (h264) like avchd but in the final cut configuration i have only 50i and 60i option in HDV and AVCHD Final cut necessit

  • How to make Form Ask for commit, when a rec is inserted when chkbox checked

    A record should be inserted when check box checked, deleted when unchecked. I have Insert/delete statement in WHEN_checkbox_changed trigger. This is happening perfectly. I want form to ask the user weither to save/ not save the changes... Please help

  • Open an Explorer from Java

    How i can open the default explorer from Java and redirect it to an especific URL?