JDBC -SQL NoMatch

Hi,
I 've tried the following to count the rows in a database....
rs = stmt.executeQuery("Select Title from Lent where UserN.equals(User_N)");
int x = 0
boolean more = rs.next()
while(more){
x++
more = rs.next();
rs.close
Is this practical or is there a better method i've overlooked?I also want to know the Java equilvant:
When searching databases.....if NoMatch occurs how do put this into the code (True/False)?eg: if my query doesn't find anymatch..i must display "File not found!".How do you set this logic in SQL/JDBC?Thanks alot!
Regards,
Aesh83

Why dont you do this, there's no looping... this could be a long expensive operation if you have LOTS of rows..
int numrows=-1;
try {
    rs = stmt.executeQuery("Select count(*) from Lent where usern=<whatever>");
    numrows=rs.getInt(1);
}catch(Exception ex){}
System.out.println("There are "+numrows+" rows...");
Hi,
I 've tried the following to count the rows in a
n a database....
rs = stmt.executeQuery("Select Title from Lent where
UserN.equals(User_N)");
int x = 0
boolean more = rs.next()
while(more){
x++
more = rs.next();
rs.close
Is this practical or is there a better method i've
overlooked?I also want to know the Java equilvant:
When searching databases.....if NoMatch occurs how do
put this into the code (True/False)?eg: if my query
doesn't find anymatch..i must display "File not
found!".How do you set this logic in SQL/JDBC?Thanks
alot!
Regards,
Aesh83

Similar Messages

  • Package jdbc.sql

    we use j2sdk1.4.2_07 and we try to import the package jdbc.sql.* in order to connect our program(which is an applet) with an oracle database, but we receive the following error:"package jdbc.sql does not exist".Does anybody know where we can find the package jdbc.sql.*?
    Thanks.

    There is no package jdbc.sql, like the compiler said. You must mean package java.sql.
    You can't connect an applet directly to Oracle. Better think again.
    %

  • I need a JDBC SQL Grammar

    Hi All,
    I'm working on a project in which I have to translate
    between SQL/400 (for the IBM AS/400) and JDBC
    SQL statements. Rather than working in the dark,
    I'd like to get a grammar for both languages. I'm
    wondering if anyone out there knows where I can
    find one or the other (or both)?
    Regards,
    Stuart ([email protected])

    Well, I wouldn't say there's a difference in grammar. Different SQL dialects use different column type numbers and treat some field types like date fields differently.
    If you want to check out our way of database independence, see subclasses of de.must.dataobj.SQLDialect at http://www.must.de/Jacompe.htm.
    Christoph

  • JDBC SQL Query Transactionality

    Hi Experts,
    If possible, please can you let me know how the JDBC SQL Query Transactionality works?
    For example, in the JDBC communication channel configuration parameters,
    if I use "SELECT * FROM orders WHERE new = 'TRUE' " for the select query and;
    if I use "UPDATE orders SET new = 'FALSE' WHERE new = 'TRUE' " for the update query;
    does the UPDATE query just update the records contained in that particular record set (for a particular polling instance)?
    What happens if someone inserts new records into the orders table just before the update query executes? Will the update query update those records too? Or just those records in the record set for a particular polling instance? How does XI/PI distinguish between the records contained in the record set for (for a particular polling instance) and the records inserted just before the update query executes?
    Thanks and regards,
    Brendon

    hi,
    as far as I remember this works correctly only when you set Transaction Isolation Levels to repeatable_read or serializable
    have a look at those levels :
    http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/TransactionIsolation.html
    so I guess both of them should prevent situations you're talking about
    Regards,
    Michal Krawczyk

  • Microsoft JDBC SQL Server Drivers

    I want to use the Microsoft JDBC SQL Server Drivers. I know they are not supported.
    What do I need to do to my 9iAS install so that my reports can use this JDBC connection.
    I have 5 simple reports I want to run from a very simnple menu. I want to hide the JDBC connection in the URL. But I want the report to use the URL to connect to a MS SQL Server 200 database and generate a report that was created using Reports Builder.
    Obviosly I am new to all of this. And someone else is doing the 9iAS install.
    What do I need to do to get this going?
    Thanks for any help.
    Jeanne

    I am now using mth Merant SQL Server JDBC Driver.
    But I still get the following error when running from the URL from my local OC4J.
    I have added classpath of YM*.jar files to rwEng and rwUrlEng in rep_<myserver>.conf.
    Why can't it find the drivers?
    Thanks.
    Reports Error Page
    Wed May 28 10:08:52 PDT 2003
    javax.servlet.jsp.JspException: rwlib-1: REP-4100: Failed to execute data source. JDBCPDS-62008:com.oracle.ias.jdbc.sqlserver.SQLServerDriver
    javax.servlet.jsp.JspException: rwlib-1: REP-4100: Failed to execute data source.
    JDBCPDS-62008:com.oracle.ias.jdbc.sqlserver.SQLServerDriver
    at oracle.reports.jsp.ObjectsTag.doEndTag(ObjectsTag.java:180)
    at test.WLBNTemp._jspService(_WLBNTemp.java:85)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:508)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:255)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:407)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:330)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:59)
    at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:523)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:735)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)

  • JDBC SQL Exception while updating an SQL database

    Hi Experts,
    Recently i have encountered a JDBC SQL exception while updating aSQL database as below,
    com.sap.aii.af.ra.ms.api.DeliveryException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'SAP_UPLOAD' (structure 'Statement'): java.sql.SQLException: No more data to read from socket
    the above system error didn't occur for all messages (so far happened twice), but i need to find an fix to overcome this system error.
    did anybody came across the above system error, please help me to resolve.
    Thanks

    Hi bandana,
    From SAP Note --> 831162
    17. Receiver: java.sql.SQLException During First Message Processing
    Q: When sending a message to a JDBC receiver channel for the first time after an extended inactivity period, I am observing a java.sql.SQLException in the adapter's processing, which refers to a closed connection or a timeout? What is causing this and how do I work around this problem?
    A: The database server has apparently closed the adapter's JDBC connection from the server side. Nevertheless, the message should be processed successfully during the next retry. If you want to completely eliminate the symptoms, enable the setting "Advanced Mode" -> "Disconnect from database after each message processing". Note that this might have a negative performance impact for high-volume processing.
    I would recommend you to go through the complete note !!! Very Informative .
    Regards,

  • Urgent OmniPortlet JDBC SQL Server - Unable to establish the connection

    Not sure if this is the correct forum but as there is another JDBC question regarding portlets in this forum I have to give this a try as it is URGENT I get this solved.
    Please see my post in the Portal General Forum
    OmniPortlet DataDirect JDBC SQL Server - Unable to establish the connection
    Thanks!

    Not sure if this is the correct forum but as there is another JDBC question regarding portlets in this forum I have to give this a try as it is URGENT I get this solved.
    Please see my post in the Portal General Forum
    OmniPortlet DataDirect JDBC SQL Server - Unable to establish the connection
    Thanks!

  • Sun.jdbc.sql.*

    to all:
    I had to use the package of "sun.jdbc.sql.*" in jsp environment(<%@page import="sun.jdbc.sql.*"%>),so have downed the component rowset.jar from sun.com and put in my CLASSPATH,but the system coudn't find the package wherever i put the rowset.jar? but it could be found in pure java environment, why?
    urgently!!
    thanks your help

    Have you told you'r servlet engine where to find it?
    (If you need a servlet engine to run a jsp..)
    In tomcat you add something like this to you'r server.xml file
    <!-- Mysql Connection -->
              <Context path="/servlet" docBase="servlet" debug="5" reloadable="true" crossContext="true">
                   <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_Absence_log."
                                  suffix=".txt" timestamp="true"/>
                   <Resource name="jdbc/AbsenceDB" auth="Container" type="javax.sql.DataSource"/>
                   <ResourceParams name="jdbc/AbsenceDB">
                   <parameter>
                        <name>factory</name>
                        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                   </parameter>
    <!-- Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->
                   <parameter>
                             <name>maxActive</name>
                        <value>100</value>
                   </parameter>
    <!-- Maximum number of idle dB connections to retain in pool.
         Set to 0 for no limit.
    -->
                   <parameter>
                        <name>maxIdle</name>
                        <value>30</value>
                   </parameter>
    <!-- Maximum time to wait for a dB connection to become available
    in ms, in this example 10 seconds. An Exception is thrown if
    this timeout is exceeded. Set to -1 to wait indefinitely.
    -->
                   <parameter>
                        <name>maxWait</name>
                        <value>10000</value>
                   </parameter>
    <!-- MySQL dB username and password for dB connections -->
                   <parameter>
                        <name>username</name>
                        <value>aUsername</value>
                   </parameter>
                   <parameter>
                        <name>password</name>
                        <value>aPassword</value>
                   </parameter>
    <!-- Class name for mm.mysql JDBC driver -->
                   <parameter>
                        <name>driverClassName</name>
                        <value>com.mysql.jdbc.Driver</value>
                   </parameter>
    <!-- The JDBC connection url for connecting to your MySQL dB.
    The autoReconnect=true argument to the url makes sure that the
    mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
    connection. mysqld by default closes idle connections after 8 hours.
    -->
                   <parameter>
                        <name>url</name>
                        <value>jdbc:mysql://<address to the server>?autoReconnect=true</value>
                   </parameter>
                   </ResourceParams>
              </Context>
    Hope it helps some

  • MATLAB-JDBC-SQL

    Hello All,
    I was playing around with MATLAB-JDBC-SQL functions, I was successful in making a connection.
    I am using MySQL database
    Here you can see an example
    java.lang.Class.forName('sun.jdbc.odbc.JdbcOdbcDriver');
    url = 'jdbc:odbc:mydb';
    url = java.lang.String(url);
    con = java.sql.DriverManager.getConnection(url,'guest','guest');
    statement=con.createStatement();
    qr='SELECT * FROM var';
    rs=statement.executeQuery(qr);
    i=1;
    while(rs.next())
    result_set.getString(i)
    i=i+1;
    end
    Now, I just want to connect directly to MySQL database without using a ODBC connection.
    for example
    java.lang.Class.forName('sun.jdbc.mysql);
    Does anyone know how to do it?
    Thank you
    likaramuk

    First you get a MySQL jdbc driver. Until you have that you can't do anything else.
    Also note that your subject title was not informative about the question you were asking.

  • JDBC SQL Server Channel Calling Stored Procedure Won't Return Result Set

    Good afternoon, Experts
    We're calling a stored procedure in a sender communcation channel.  I can perform any SQL SELECT statement here, but for some reason when I execute the SP (EXECUTE StoredProcedureName) The Adapter Engine returns the following:
    Database-level error reported by JDBC driver while executing statement 'DECLARE @UpdateRecords bit SET @UpdateRecords = 0 EXECUTE ExportToSAP @UpdateRecords'. The JDBC driver returned the following error message: 'com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.'. For details, contact your database server vendor.
    Even stranger yet is is that this works just fine on our PI-DEV system.  I created an identical communication channel connecting to the same database with the same UID and PWD and it won't work in PI-QAS.
    Any help/ideas you could share would be greatly appreciated!!!
    Thanks,
    Chad

    Hi Chad.
    Normally, itu2019s a problem with your procedure. The Store Procedure is wrong and something is different between your DEV environment and QAS environment.
    Try to ask to DB team check it.
    Regards,
    Bruno

  • Problem in JDBC-SQL Server connection string

    Anyone could help me to write proper connection string using JDBC with SQL Server 2000. The descp:
    Server name: CD
    databaseName: songs
    Using Window NT authentication.
    I dont know whether to include username and password.
    When I executed the statement below:
    DriverManager.getConnection("jdbc:microsoft:sqlserver://CD:1433;databaseName=songs");
    Recieved error: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket
    Plz help!! Thank you very much.

    Look at the URl below:
    How to connect to Microsoft SQL server with Type 4 JDBC driver
    http://www.java-tips.org/content/view/615/29/

  • JDBC (SQL) not working in thread

    I was surprised by a strange (bug?)
    I had two programs that were implementing the Java Serial Port API, each interfaced to a specific instrument. I was asked to combine the two programs into one, run it on one workstation, and run it as a service. This is on an W2K machine and they want it to work even if no one is logged in.
    Well, I started each class as a serial port listener and a runnable, thinking it might be best for each listener to have its own thread. That runs just fine. But, one of the instruments sends a lot of data, so once I had a buffer full of stuff to parse and upload (to Oracle), is started another processing thread to handle the data, and let the parent thread get back to listening to the serial port.
    Well, I parsed the data just fine, but after I created the connection, created a statement, and then tried to execute a line of SQL, it just stopped, no exceptions, but no results. I keep a log of what is going on, and it looks like the thread just dies.
    So, for experimenation, I changed the parent threads back to plain classes and created the instances of them, still leaving the processing piece as a thread. (The only draw back to this is that I cannot transmit from both instruments at the same time.) Well, the SQL worked fine, so I am wondering if there is a problem with the JDBC and threads, or inner threads?
    Anyone have any suggestions?
    Thanks,

    As I understand it, your code does not work only when you run it as a service. Although I may well not understand it (for example I don't know what you think an "inner" thread is, and I don't understand your distinction between "class" and "thread", since everything runs in some thread or other in Java).
    Is this correct? Have you managed to get the original (single instrument) code running as a service? My guess is that there's nothing wrong with Java, but there is some issue with running it as a service.

  • JDBC -- SQL Server 2000

    I am using JDK 1.5 and I want to make a connection to Microsoft SQL Server 2000. I got the driver from the site of Microsoftand named Microsoft SQL Server 2000 JDBC Driver Service Pack 3. This was the latest version of this driver. And have used this code to test the driver:
    =====================================================
    import java.sql.*;
    * Microsoft SQL Server JDBC test program
    public class Test {
    public Test() throws Exception {
    // Get connection
    DriverManager.registerDriver(new
    com.microsoft.jdbc.sqlserver.SQLServerDriver());
    Connection connection = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://EXPERT:1433;User=sa;Password=123");
    if (connection != null) {
    System.out.println();
    System.out.println("Successfully connected");
    System.out.println();
    // Meta data
    DatabaseMetaData meta = connection.getMetaData();
    System.out.println("\nDriver Information");
    System.out.println("Driver Name: "
    + meta.getDriverName());
    System.out.println("Driver Version: "
    + meta.getDriverVersion());
    System.out.println("\nDatabase Information ");
    System.out.println("Database Name: "
    + meta.getDatabaseProductName());
    System.out.println("Database Version: "+
    meta.getDatabaseProductVersion());
    } // Test
    public static void main (String args[]) throws Exception {
    Test test = new Test();
    ====================================================
    but it doesn't work. the error is:
    Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
         at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
         at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
         at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
         at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
         at com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
         at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
         at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
         at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
         at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
         at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at Test.<init>(Test.java:10)
         at Test.main(Test.java:31)
    ====================================================
    Can anybody help me to find a solution?

    Hi,
    The Microsft JDBC driver supplied by Microsoft does not work for local SQL Server run on Windows2000 professional/personal. If your local OS is Windows 2000 Server, then the JDBC Driver supplied from the microsoft website may work.
    (I am not sure about other Windows OS' like XP/95/98 etc.)
    As a workaround you can use an alternative driver from JTDS or drivers from DataDirect Connect.
    I faced similar issue as yours trying to connect to the local SQL database running in my machine with OS Windows2000 professional. I was able to solve the issue and connect to the DB when I used the JTDS Driver from sourceforge.net. This is an free software open source from GNU.
    JTDS is a Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000 and 2005) and Sybase (10, 11, 12).
    You can also check for DataDirect's driver in the following URL
    DataDirect Connect for JDBC driver
    http://www.datadirect.com/products/jdbc/comparing_with_microsoft/index.ssp
    Hope this helps. Please post a reply if the above solution works!
    Thanks,
    Nakshathram.

  • Use of Remote JDBC  SQL Database External Resource

    Does anybody here uses a Remote JDBC External Resource to connect to a database? If so, can you tell me if had any impediment with this approach?
    I'm asking this because our company has a lot of tools to monitor a lot of weblogic assets (such as jdbc connection pools and datasources) and We'd like to monitor all BPM-to-database connections usage and pool health. Other feature that we'd like to give to BPM application is the weblogic's capability to use an Multi-DataSource (one logical DS that represents more than one phisical DS).
    Thanks and Best Regards,
    Luiz Rocha

    Hi,
    We are facing connection leak in our application .We have defined External resouce as Remote JDBC which is defined in weblogic config.Xml. If any body could explain is there is anyway to handle closing connections manually as we do in J2ee conn.close() in ALBPM ??? . I found runtime configuration in oracle implementation type when defining external resource (i.e supported type:oracle database) an attribute
    "*Connection idle time* (mins): The connection is closed after the defined time"
    But i dont find any equivalent entry in my config.xml as we do our implementation of type Remote JDBC.....
    Any advice on this and how connection closing happens in Normal scenarios within ALBPM will be very useful.
    Our connection pool attributes reads like.....(Note *the values of few attributes deleted)
    <JDBCConnectionPool AddOracleFlagToXAResource="true"
    CountOfTestFailuresTillFlush="1"
    DriverName=""
    InitialCapacity="150" KeepXAConnTillTxComplete="true"
    MaxCapacity="200" Name=""
    PasswordEncrypted=""
    Properties="user=" ShrinkingEnabled="false"
    SupportsLocalTransaction="true" Targets=""
    TestConnectionsOnCreate="false" TestConnectionsOnRelease="false"
    TestConnectionsOnReserve="true"
    TestTableName="SQL SELECT 1 FROM DUAL"
    URL=""
    XARetryDurationSeconds="300" XASetTransactionTimeout="true" XATransactionTimeout="420"/>
    .Advice us can the below attribute can be added in Connection pool properties or anything else......
    **{[(*Inactive Connection Timeout The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool.***
    ***You can use the Inactive Connection Timeout feature to reclaim leaked connections - connections that were not explicitly closed by the application. Note that this feature is not intended to be used in place of properly closing connections.***
    ***When set to 0, the feature is disabled*.)}]**

  • Jdbc sql insert to oracle DB.

    Dear All,
    I'm using the jdbc connector to insert data directly into an Oracle database table.  I've got the SQL insert command which XI has generated by using the logSQLStatement parameter and I've proved the statement is good by pasting it directly into Toad where it is executed perfectly.  However XI is throwing the following errors;-
    Unable to execute statement for table or stored procedure. 'SI_ORDER' (Structure 'STATEMENT') due to java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
    MP: exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'SI_ORDER' (structure 'STATEMENT'): java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
    Does anyone know what might be the problem or even where I should start to troubleshoot this?
    Any help is much appreciated.
    Pete.

    Your question is how to load data from a text file into arrays?
    Start with a
    StreamReader to read the file one line at a time.  Then break each line into individual values, and add each value to a
    List<T>.  Then call .ToArray() on each list to set the value of each array-bound parameter.
    David
    David http://blogs.msdn.com/b/dbrowne/

Maybe you are looking for