Example: JDBC Callable Produre for Stored SQL in MS Access

I searched the net to find how this works. Firing a select and getting a resultset. I found certain pointers but couldn't find a complete solution. Although this would seem as not necessary but could be needed by a student or someone working with Access for the portability of it.
It was accomplished using JDBC-ODBC.
This is the stored query in the mdb : "getPassword"
{color:#0000ff}
SELECT password FROM Admin WHERE name=@username;
{color}
This is the DBMS using class: "XYZDatabase.java"
{color:#ff0000}
import java.sql.*; public class XYZDatabase { Connection con; CallableStatement cstmnt; Statement stmnt; ResultSet results; public XYZDatabase() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:XYZBuses"); stmnt = con.createStatement(); } catch(ClassNotFoundException e) { System.out.println("err in class 1:" e); } catch(SQLException e) { System.out.println("err in sql 1:" e); } } public void finalize() { try { stmnt.close(); con.close(); } catch(SQLException e) { System.out.println("err in sql 2:" e); } } public boolean checkPassword (String username, String password) { String pass = null; try { cstmnt = con.prepareCall("{exec getPassword ?}"); cstmnt.setString(1,username); cstmnt.execute(); results = cstmnt.getResultSet(); while(results.next()) pass = results.getString(1); cstmnt.close(); } catch(SQLException e) { System.out.println("err in sql 3:" e ); e.printStackTrace(); } System.out.println(pass); if (pass==null) return false; else if (password.equals(pass)) return true; return false; } }
{color}{color:#000000}This one is invocation : "Tester.java"
{color}{color:#008000}
public class Tester { public static void main (String args[]) { XYZDatabase db = new XYZDatabase(); System.out.println(db.checkPassword("imran","imran")); } }
{color}{color:#000000}Hope someone would find it handy someday :)
{color}

ImranZunzani wrote:
I searched the net to find how this works. [http://forums.sun.com/thread.jspa?threadID=203818&range=1&start=6&forumID=48]

Similar Messages

  • JDBC Connection String for MS Sql Server 2000 with Instance Name

    Hi All,
    I am having problems connecting to a MS Sql Server 2000 database using MSSqlServer4
    driver when the database server has an Instance Name. If the database server has
    no instance name then I am able to connect using the connection string
    connection=jdbc:weblogic:mssqlserver4:hansa:1433
    But when I have the MS Sql Server DB with an instance name such as "TestInstance",
    then I am unable to connect with any of the connection strings given below
    connection=jdbc:weblogic:mssqlserver4:hansa\TestInstance:1433 or
    connection=jdbc:weblogic:mssqlserver4:hansa\\TestInstance:1433 or
    connection=jdbc:weblogic:mssqlserver4:hansa:TestInstance:1433 or
    connection=jdbc:weblogic:mssqlserver4:hansa:1433:TestInstance
    Can anybody help me in resolving this issue. Appreciate your help.
    Thanks in advance.
    Vikram

    Vikram wrote:
    Hi All,
    I am having problems connecting to a MS Sql Server 2000 database using MSSqlServer4
    driver when the database server has an Instance Name. If the database server has
    no instance name then I am able to connect using the connection string
    connection=jdbc:weblogic:mssqlserver4:hansa:1433
    But when I have the MS Sql Server DB with an instance name such as "TestInstance",
    then I am unable to connect with any of the connection strings given below
    connection=jdbc:weblogic:mssqlserver4:hansa\TestInstance:1433 or
    connection=jdbc:weblogic:mssqlserver4:hansa\\TestInstance:1433 or
    connection=jdbc:weblogic:mssqlserver4:hansa:TestInstance:1433 or
    connection=jdbc:weblogic:mssqlserver4:hansa:1433:TestInstance
    Can anybody help me in resolving this issue. Appreciate your help.Hi. No type-4 jdbc driver is going to be able to use a name for a DBMS instance.
    Let's assume you have two DBMS instances running on the machine hansa. One
    of them may be listening for tcp connections on port 1433, but the other must not.
    The other most be listening on some other port number you have chosen.
    Therefore, to choose which DBMS instance you want to connect to, use the
    working URL you have, and switch the port number as desired.
    Joe Weinstein
    >
    >
    Thanks in advance.
    Vikram

  • JDBC 1.2 for SQL 2008

    Hi Gurus,
    I searched in SAP Marketplace and saw that the JDBC adapter 1.2 posted there is for SQL 2005 server only. May I know where I can download a JDBC 1.2 adapter for the 2008 SQL server? I'm working with XI 7.0.
    Thanks all.
    Regards,
    SAPenthusiast

    Hello,
    Check these notes:
    Note 639702 - JDBC Driver for Microsoft SQL Server
    Note 1600699 - Microsoft jdbc driver 1.2 support
    I think you can just use the JDBC 1.2 that appears for download in SQL Server 2005. Check http://msdn.microsoft.com/en-us/sqlserver/aa937724 for example. The same driver is used to connect different DB versions.
    Cheers,
    Diego.

  • Using command-line util for wrapping SQL Server stored procedure

    Hi,
    The Database Adapter does not have native support for stored procedures in SQL Server. Hence, I intend to use the command-line utility that is described briefly in the DB Adapter guide, i.e. the thing that is invoked using "java oracle.tip.adapter.db.sp.artifacts.GenerateArtifacts <property file>".
    Has anyone used this before? And did you have any success?
    Any help appreciated.
    Thanks, Sjoerd

    Yet another correction ...
    My JD is installed to D:\JDS10gSOA; so ...
    I created a bat file with the following jars listed:
    java -cp D:\JDS10gSOA\integration\lib\DBAdapter.jar;D:\JDS10gSOA\integration\lib\bpm-infra.jar;D:\JDS10gSOA\integration\lib\orabpel.jar;D:\JDS10gSOA\lib\xmlparserv2.jar;D:\JDS10gSOA\lib\xschema.jar;D:\JDS10gSOA\toplink\jlib\toplink.jar;D:\JDS10gSOA\integration\lib\connector15.jar;D:\JDS10gSOA\jars\sqljdbc.jar oracle.tip.adapter.db.sp.artifacts.GenerateArtifacts %1
    Note the \jars\ folder I created and copied the MS jdbc driver in there; it's needed in a couple of other places as well.
    A sample properties file:
    ProductName=Microsoft SQL Server
    DriverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
    ConnectionString=jdbc:sqlserver://localhost\\SQLEXPRESS;databaseName=helloworlddb;user=hello;password=hello
    ProcedureName=helloWorldProc
    ServiceName=srv_helloWorldProc
    DatabaseConnection=eis/DB/helloworlddb
    Hope this helps.
    I have to agree the document is very vague on this; no good script or anything from oracle on getting this done - even though it's an integral part of SOA in my opinion.
    Regards

  • C# Code Example for Configuring SQL 2005 Reporting Services?

    I have found the MSDN articles describing the classes, public methods, etc. for configuring SQL Server 2005 Reporting Services via WMI. I need to initially configure them and just do this:
    - Report Server Virtual Directory
    - Windows Service Identity
    - Web Service Identity
    - Database Setup
    - Email Settings
    - Execution Account
    Is there a C# code example that already exists putting together all of this? I didn't want to reinvent the wheel if I didn't need to.
    -Ed

    Jin,
    Thanks so much! This is great! Your work is awesome!
    I have a couple of issues that came up...
    1) CreateVirtualDirectory.vbs creates the virtual directory for the Report Server just fine. Now how do I distinguish a script to create the virtual directory for the Report Manager?
    2) I decided to go ahead and use what you did for scripting CreateApplicationPool (using http://msdn.microsoft.com/en-us/library/ms155349(SQL.90).aspx). I found the syntax is wrong here when I kept getting an error, so I put PowerShell on the server and pulled the following info:
    Name       : CreateApplicationPool
    MemberType : Method
    Definition : System.Management.ManagementBaseObject CreateApplicationPool(System.String Name, System.Boolean UseBuiltIn
                 Account, System.String Account, System.String Password)
    However, I'd like to use "NT Authority\NetworkService" or "Network Service" as the account (which is an option for the Builtin accounts when I us RSConfigTool.exe). This is the syntax I used:
    objInParam.Properties_.Item(
    "Name") = "ReportServer"
    objInParam.Properties_.Item("UseBuiltInAccount") = true
    objInParam.Properties_.Item("Account") = "NT Authority\NetworkService"
    objInParam.Properties_.Item("Password") = ""
    But I always get an error with a negative number for the HRESULT.
    Any ideas?-Ed

  • Cannot establish connection - JDBC driver for MS SQL server 2000

    Hi,
    We are facing problems in connecting to SQL server 2000.
    We have installed the latest version of the driver from followin link and following
    https://websmp108.sap-ag.de/msplatforms    > SQL Server > JDBC Driver for MS SQL Server (Version 3.70.10)
    We have given the following entries in our communication channel:
    JDBC Driver : com.microsoft.sqlserver.jdbc.SQLServerDriver
    Connection:  jdbc:sqlserver://<SQLserver IP>:1433;databaseName=production_info
    Please let us know the procedure to find if the JDBC driver for SQL 2000 is installed from our SAP XI.
    ERROR DETAILS:
    Error during database connection to the database URL 'jdbc:sqlserver://<SQLserverIP>:1433;databaseName=production_info' using the JDBC driver 'com.microsoft.sqlserver.jdbc.SQLServerDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:sqlserver://<SQLserverIP>:1433;databaseName=production_info': SAPClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver'
    Please help.
    Regards,
    Rehan

    Hi Chris,
    We have used the same because we have downloaded the driver from following location
    https://websmp108.sap-ag.de/msplatforms ;   > SQL Server > JDBC Driver for MS SQL Server (Version 3.70.10)
    I have tried with both "com.microsoft.jdbc.sqlserver.SQLServerDriver"; and "com.microsoft.sqlserver.jdbc.SQLServerDriver";, but still I am facing the same error.
    Service market place has given the driver as "JDBC Driver for MS SQL Server (Version 3.70.10)", is there a way to find out if it is for 2000 or 2005?
    Thanks for your reply.
    Regards,
    Rehan

  • JDBC Receiver adapter  configuration for MS SQL

    Hi friends,
    I have configured receiver jdbc adapter for MS SQL database which are as follows:
    jdbc driver : com.microsoft.sqlserver.jdbc.SQLServerDriver
    connection: jdbc:sqlserver://USLABWDB01:1433;DatabaseName=Central_Lab_BIDB
    In communcation channel i am getting following error:
    Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error when attempting to get processing resources: com.sap.aii.af.service.util.concurrent.ResourcePoolException: Unable to create new pooled resource: DriverManagerException: Cannot establish connection to URL 'jdbc:sqlserver://USLABWDB01:1433;DatabaseName=Central_Lab_BIDB': UnsupportedClassVersionError: com/microsoft/sqlserver/jdbc/SQLServerDriver (Unsupported major.minor version 49.0)
    Kindly tell me what is the root cause of the issue.
    Renu.

    Hi Renu,
    Try foll. 2 steps:
    1) Add the IP address of the server(USLABWDB01) to the host file of your PI server, as you are connecting using Hostname.
    2)Try the following connection strings:
        jdbc driver : com.microsoft.jdbc.sqlserver.SQLServerDriver
        connection: jdbc:microsoft:sqlserver://USLABWDB01:1433;DatabaseName=Central_Lab_BIDB
       Here, 'microsoft' word is added in connection string.
    Try using this, it should work.
    -Tanaya.

  • Stored Procedures for Simple SQL statements

    Hi Guys,
    We are using Oracle 10g database and Web logic for frontend.
    The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
    Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
    I have gathered some list for using PL/SQL procedure for simple select queries like
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
    Simple select statements are much faster than executing them from Procedure
    Pros
    Code changes for modifying select query in PL/SQL much easier than in Java
    Your help in this regard is more valuable. Please post your points / thoughts here.
    Thanks & Regards
    Srinivas
    Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PM

    Srinivas_Reddy wrote:
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
    On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
    Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
    Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
    Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
    Pros
    Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
    I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client.

  • ALDSP 3.0 -- schema owner for stored procedure or SQL Statement

    Using ALDSP, I have a need to create a physical service based on a stored procedure or a SQL statement. I am wondering what will happen when I move to another deployment environment where the schema owner changes. In our QA and Prod environments, we have a different schema owner for all tables in the application (the DBAs believe this prevents unwanted updates to a prod environment). DSP elegantly supports this for normal table- and view-based physical services by mapping schemas through the DSP console after deployment. Will I get the same type of mapping capability for stored procedures and SQL statements? I noticed that I can add a SQL-based function to a physical service...is there a way to pass in the physical table name from that data service to the procedure or SQL statement?
    Thanks,
    Jeff

    Schema name substitution should work for stored procedures just like it does for tables. If it doesn't - report a bug.
    You don't get any help for sql-statement based data services - dsp doesn't parse the sql provided. One thing you could do is use the default schema (following the user of your connection pool), and not specify the schema in your sql-statement.

  • JDBC Connector in SAP Netweaver for CE 7.1 EHP1 for Stored Procedures

    Hi ALL,
    I basically want to access the database tables in Maxdb ( R/3 System )directly in my Visual Composer V 7.1 Search tab.
    In the new Ehp1 it offers a JDBC system connector for connecting stored procedures.
    I have tried connecting using the JDBC System Connector, although the connection tests are sucessful , the system alias name of the conneciton doesnt show up in the search tab of visual composer.
    Can anyone suggest me anything to slove this problem?
    Regards

    Hi Deepa,
    Where have you configured this system? In the portal?
    Regards,
    Natty

  • Jdbc Driver for MS SQL Server

    i want the JDBC Driver for MS SQL Server.
    is it available free?
    thanks in advance

    Install the SQL Server 2000 Driver for JDBC Service Pack 3.
    http://www.microsoft.com/downloads/details.aspx?FamilyID=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The SQL Server JDBC driver JAR files msbase.jar, mssqlserver.jar and msutil.jar get installed in the C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib directory.

  • JDBC for MS SQL Server 2000

    Hi all, i'm newbie here and i have some problems doing with Java for my Final Project, just for my graduation...
    Here's the problem ...
    First i install the JDK 1.5 and MS SQL Server 2000. And then i also install JDBC for MS SQL Server 2000 sp3. Than i'm doing some experiments with JDBC, but its result error that i couldnt understand how to fixed it...
    I'm asking is JDBC for MS SQL Server 2000 sp3 doesn't support j2ee 1.5.0 and where i can find native driver jdbc for MS SQL Server 2000.
    Please help me....

    Than i'm doing some experiments with JDBC, but
    its result error that i couldnt understand This is the most important part of your post yet you don't seem to recognize it as such.
    Tell us what the error is. Not what you think it is. Exactlly what it says. And please provide a relevent, formatted snippet of code.

  • JDBC for Microsoft SQL Server 2000

    Hello,
    I have installed Microsoft SQL Server 2000 to establish a connection with JDK 1.4.1 and run the following code:
    import java.sql.Connection.*;
    import java.sql.*;
    public class Connect
    private java.sql.Connection con = null;
    private final String url = "jdbc:microsoft:sqlserver://";
    private final String serverName= "localhost";
    private final String portNumber = "1433";
    private final String databaseName= "cbi";
    private final String userName = "sa";
    private final String password = "";
    // Informs the driver to use server a side-cursor,
    // which permits more than one active statement
    // on a connection.
    private final String selectMethod = "cursor";
    // Constructor
    public Connect(){}
    private String getConnectionUrl()
    return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";
    private java.sql.Connection getConnection()
    try
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password);
    if(con!=null)
    System.out.println("Connection Successful!");
    catch(Exception e)
    e.printStackTrace();
    System.out.println("Error Trace in getConnection() : " + e.getMessage());
    return con;
    Display the driver properties, database details
    public void displayDbProperties()
    java.sql.DatabaseMetaData dm = null;
    java.sql.ResultSet rs = null;
    try
    con= this.getConnection();
    if(con!=null)
    dm = con.getMetaData();
    System.out.println("Driver Information");
    System.out.println("\tDriver Name: "+ dm.getDriverName());
    System.out.println("\tDriver Version: "+ dm.getDriverVersion ());
    System.out.println("\nDatabase Information ");
    System.out.println("\tDatabase Name: "+ dm.getDatabaseProductName());
    System.out.println("\tDatabase Version: "+ dm.getDatabaseProductVersion());
    System.out.println("Avalilable Catalogs ");
    rs = dm.getCatalogs();
    while(rs.next())
    System.out.println("\tcatalog: "+ rs.getString(1));
    rs.close();
    rs = null;
    closeConnection();
    else
    System.out.println("Error: No active Connection");
    catch(Exception e)
    e.printStackTrace();
    dm=null;
    private void closeConnection()
    try
    if(con!=null)
    con.close();
    con=null;
    catch(Exception e)
    e.printStackTrace();
    public static void main(String[] args) throws Exception
    Connect myDbTest = new Connect();
    myDbTest.displayDbProperties();
    but, I received the error that ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver, No active Connection.
    I added the 3 .jar files msbase.jar,mssqlserver.jar and msutil.jar to the System variables but it is not working. Is there any syntax for adding these .jar files to the System Variables?
    Please, help me and give me the solution for establishing the connection and loading the driver class. If I am doing anything wrong then please, tell me the right step.
    I am developing a project on Java and I have very little time left to accomplish it. Please help me.
    Thankyou.

    I had already given the .jar files to the User variables and System Variables but the driver class is still not loading. I had simply given the .jar file name for instance, msbase.jar;mssqlserver.jar;msutil.jar and also tried the path of .jar files i.e., C:\Microsoft SQL Server\-----------\lib\msbase.jar;C:\-------------lib\mssqlserver.jar;C:\----------------\lib\msutil.jar; but, both ways are not working. When I installed the MS SQL Server 2000 then in the lib folder, the 3 JAR files were not installed then, I downloaded a driver for MS SQL Server 2000 Driver for JDBC sp2, then, the JAR files were installed. Then, I copied those files to the lib folder of MS SQL Server and gave that path to the User and System Variables but it didn't work then I gave the original path of files where they are installed i.e., of the Driver's path which I downloaded from Microsoft but still now, my problem is not solved. Please help me.

  • SQLDeveloper 3.1 EA3 -- error installing JTDS JDBC Driver for Microsoft SQL

    After installing sqldeveloper64-3.1.06.82-no-jre.zip I get an error when trying to add the "JTDS JDBC Driver for Microsoft SQL Server" extension.
    The error returned is an invalid URL.
    The URL is http://download-llnw.oracle.com/otn-pub/sqldeveloper/oracle.sqldeveloper.thirdparty.drivers.sqlserver.58.17.zip

    Hi Chris,
    A bug was logged for this a few days ago:
    Bug 13547400 - CHECK UPDATES FAILS DUE TO SERVER RETURNED HTTP RESPONSE CODE: 400
    This is similar to another bug which has already been fixed (not a product bug, just a bad URL in an OTN web page):
    Bug 13530787 - 3.1 EA2: FORUM: CHECK FOR UPDATE HAS BAD URL FOR CVS
    3.1EA2 Sqldeveloper Updates Fail to install
    So I imagine yours will get fixed soon.
    Regards,
    Gary
    SQL Developer Team

  • Does BEA have JDBC 2.0 compliant drivers for MS-SQL 7?

    Does BEA have JDBC 2.0 compliant drivers for MS-SQL 7?Thanks in advance for your reply.

    No. You might want to look at the MERANT JDBC drivers. They might help.
    Shiva.
    Anil Nair wrote:
    Does BEA have JDBC 2.0 compliant drivers for MS-SQL 7?Thanks in advance for your reply.

Maybe you are looking for