Accessing database Variables using JDBC

Hi,
I have a question for some of you Java specialists out there.
I want to execute a select statment in my database (SQL Server 2000) and store the output in a variable. - The reason I am not directly executing the SQL statement from my JDBC connection is that I need to execute a number of SQL statements and then finally would like to store my result set in a variable in the database - NOW, my question is , how do I (If I can) access a database variable using either servlets or JSP. Any help is welcome.
A quick response would be much appreciated.
thanks

We are probably talking about different things.
ASP, at least when I used consisted of the following:
-html
-server side script (vbscript, javascript, perlscript)
-client side script (usually javascript but it could be vbscript and perlscript)
In the above you have three possible kinds of variables java, perl, vb. In each of those languages you can use SQL text to manipalate data in the database. However the text itself never ran in the ASP server nor was there such a thing a SQLscript, so there was nothing that was a SQL variable.
However, if I write a stored procedure in Oracle, it can definitely have variables. And likewise a oracle package can have variables. But there is no way to directly use those variables in ASP. The value of the variable would have to be returned to the ASP script language and a variable in tha language could contain that value.
Perhaps I just don't understand ASP or it has evolved in the last 3 years. If so then ignore everthing I have said.

Similar Messages

  • Can we directly access database by using BI Accelerator ?

    Hi Experts,
    I have several question about BIA NetWeaver2004:
            1. Can we directly accessing database by using BIA?
            2. What is advantage and disadvantage of BIA? Why'd some people rather use BIA than Aggregates?
            3. Could anyone show me the example or demonstration about BIA
    I am a newbie in BI, so please give me information about BIA.
    Thanks a bunch.

    Hi,
    Welcome to SDN. Remember the rule --- before posting, you should search the forum first.
    1. Can we directly accessing database by using BIA?
    ---> No.
    2. What is advantage and disadvantage of BIA? Why'd some people rather use BIA than Aggregates?
    --> search SDN
    3. Could anyone show me the example or demonstration about BIA
    --> search SDN
    Thanks...
    Shambhu
    Edited by: Shambhu Kumar Gupta on Mar 17, 2009 11:22 AM

  • Accessing ICS variable using EL

    Can we access ics variable using EL. Hope this query is already posted. but I tried the solution. it is not working
    I have set an  ics variable in a CSElement and I tried to access that in the next line using EL. but I am not getting the values
    e.g
    <%
    ics.SetVar("testvar","testvalue")
    %>
    fetching value using cs : {cs.testvar}
    fetching value using ics : {ics.testvar}
    No results for both the line. Is it not possible to access ics object using EL?

    Hello
    Could you try something like:
    e.g
    <%
    ics.SetVar("testvar","testvalue")
    %>
    fetching value using cs : ${cs.testvar}
    Hope it helps.
    Gerardo

  • How to access Websphere variables using java

    Hi
    I want to access Websphere variables using java.
    Any help is appreciated!!
    Thanks
    P

    WebSphere Application Server has a bunch environmental variables such as log locations. These are held at the "server", "node", and "cell" level.
    To access them, you have to get the right context. Something like this, I believe...
    InitialContext initialContext = new InitialContext();
    initialContext.lookup("foo:bar/baz/blah"); //correct context hereGo to the IBM website for WAS and do a search on namespace bindings. That should give you some more information.
    Good luck.

  • Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency

    I need to insert multiple rows into a database table using the JDBC adapter (receiver).
    I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
    Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?

    Hi Bhavesh/Kanwaljit,
    If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
    Why i am saying this?
    If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
    <i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
    Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
    Doesnt this mean that rows are inserted one by one?
    Correct me if i am wrong.
    This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
    Regards,
    Sumit

  • Is there a way to retrieve data from database wihout using JDBC while using JPDK?

    Hi,
    I want to create a portlet using JPDK with extra render modes and edit/Edit defaults mode too. The detail and show renderer mode jsp's/servlets render data from database. Based on the personalized paramter, the data rendered in detail and show mode will be obtained from database.
    The articles in the PDK zip asks not to use JDBC for security vulnerability. Does that mean , I should not use JDBC to connect to db to get data. If not, what should I use ? How do I connect to database ? Is there any class which helps to connect to db without using JDBC ?
    thanks,
    Mainak

    I'm not sure what articles you are refering to, because there is no other way to access a database from a java program. Generally, security related docs tend to be a little paranoid (and so they should be), but you have to balance high security against getting the job done.
    Obviously, if using JDBC, you need to be careful about protecting your config files because they will contain connection information.

  • Error due to accessing database connection using jsp

    Hi,
    I have an error, during accessing a datbase using jsp:useBean from jsp.Urgent i need this one
    my source code is
    DbBean.java
    package SQLBean;
    import java.sql.*;
    import java.io.*;
    public class DbBean implements java.io.Serializable{
    private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
    private Connection dbCon;
    public DbBean(){
    super();
    public boolean connect() throws ClassNotFoundException,SQLException{
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
    return true;
    public void close() throws SQLException{
    dbCon.close();
    public ResultSet execSQL(String sql) throws SQLException{
    Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
    public int updateSQL(String sql) throws SQLException{
    Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    database.jsp
    <HTML>
    <HEAD><TITLE>DataBase Search</TITLE></HEAD>
    <BODY>
    <%@ page language="Java" import="java.sql.*" %>
    <jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />
    <jsp:setProperty name="db" property="*" />
    <center>
    <h2> Results from </h2>
    <hr>
    <br><br>
    <table>
    <%
    db.connect();
    ResultSet rs = db.execSQL("select * from employ");
    int i = db.updateSQL("UPDATE employ set fname = 'hello world' where empno='000010'");
    out.println(i);
    %>
    <%
    while(rs.next()) {
    %>
    <%= rs.getString("empno") %>
    <BR>
    <%
    %>
    <BR>
    <%
    db.close();
    %>
    Done
    </table>
    </body>
    </HTML>
    The error like this
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    error: Invalid class file format in C:\Program Files\Apache Tomcat 4.0\webapps\muthu\WEB-INF\classes\SQLBean\DbBean.class. The major.minor version '49.0' is too recent for this tool to understand.
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:65: Class SQLBean.DbBean not found.
    SQLBean.DbBean db = null;
    ^
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:68: Class SQLBean.DbBean not found.
    db= (SQLBean.DbBean)
    ^
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:73: Class SQLBean.DbBean not found.
    db = (SQLBean.DbBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "SQLBean.DbBean");
    ^
    4 errors, 1 warning
    Anybody help me?
    Thanx in advance

    Your code is ok . The problem is in java version witch you use to compile the DbBean class . I think you are using java 1.5 try to change to 1.4 compile and run again should help .

  • Access database/ java application/ jdbc odbc

    i am building an access database with a java application and get the following error message when i try to run the application. the log in window that i have does not have a password text field, only a field for the odbc name.
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Not a valid password.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2488)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:317)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:160)

    User/password are usually necessary to set up the ODBC source. So you may need find out who set up your ODBC source. Or you need find the correct user/password and reset the ODBC source.
    PC

  • How to access oracle cursors using jdbc (expecting ur earliest reply)

    Hi All,
    can anyone help me out by giving me an idea or sample code in accessing the cursors that are defined in the oracle... i have to access those cursors using java... Thanks in advance for your reply and time....
    Ragu

    I have tried to follow the example from the URL link you provided.
    I'm using :
    - Oracle 8.1.6/8.1.7
    - JDK 1.3.1
    I've created:
    create or replace package types
    as
    type cursorType is ref cursor;
    end;
    create or replace function sp_ListEmp return types.cursortype
    as
    l_cursor types.cursorType;
    begin
    open l_cursor for
    select ename, empno
    from emp
    order by ename;
    return l_cursor;
    end;
    Then I have on my code the following:
    import java.sql.*;
    import oracle.jdbc.driver.*;
    String conStatus = "":
    String driver_class = "oracle.jdbc.driver.OracleDriver";
    String connect_string = "jdbc:oracle:thin:@slackdog:1521:oracle8";
    String query = "begin :1 := sp_listEmp; end;";
    Connection conn;
    Class.forName(driver_class);
    conn = DriverManager.getConnection(connect_string, "scott", "tiger");
    try{
    conStatus = "before prepareCall, ";
    CallableStatement cstmt = conn.prepareCall(query);
    conStatus = conStatus + "before Register out, ";
    cstmt.registerOutParameter(1,OracleTypes.CURSOR);
    conStatus = conStatus + "before execute, ";
    cstmt.execute();
    conStatus = conStatus + "before getObject, ";
    ResultSet rset = (ResultSet)cstmt.getObject(1);
    while (rset.next ())
    System.out.println( rset.getString (1) );
    cstmt.close();
    } catch (Exception e) {
    conStatus = conStatus + e;
    System.out.println(conStatus);
    What happens is that I am able to successfully compile the code. But when I run the code, it displays:
    "before prepareCall, before Register out, SQLException: incompatible types = -10."
    What does that mean? Pls point out to me what I did wrong in my code.
    Thanks.

  • Update MS Access Database table using ABAP

    Hi All,
    I have a requirement wherein I have to update the existing records in MS Access database using ABAP Code. Can someone provide sample code through which I can achieve this. Thanks!!!
    Regards,
    Nitish Reddy.
    Edited by: Nitish Cherukupally on Mar 30, 2009 4:02 PM

    hi,
    please refer to this link
    http://learningabap.wordpress.com/2007/04/11/get-data-from-ms-access-into-internal-table/
    http://abapcode.blogspot.com/2007/05/get-data-from-ms-access-into-internal.html
    http://abapcode.blogspot.com/2007/06/sample-program-to-upload-excel-document.html
    MS Access Database using ABAP Program
    thanks

  • Accessing Private variable using reflection

    Is someone have code snippet for accessing private varaible using reflection
    Here is my code snipper
    import java.lang.reflect.Field;
    public class test1234 {
    private String t;
    public test1234() {
    public String show() {
    return t;
    import java.lang.reflect.Field;
    public class Test123 {
    public Test123() {
    public static void main(String[] args) {
    test1234 test12341 = new test1234();
    try {
    Class cls = test12341.getClass();
    Field fld = cls.getField("t");
    fld.set(test12341, "12");
    catch (Exception e) {
    System.out.println(e.getLocalizedMessage());
    I am getting exception when i try to access.
    java.lang.NoSuchFieldException
         at java.lang.Class.getField0(Native Method)
         at java.lang.Class.getField(Class.java:826)
         at Test123.main(Test123.java:24)
    Thanks in advance

    Thanks for your response. After setting accessible to true i can able to set into private variable.
    Thanks a lot.

  • How Can I connect to a Microsoft Access Database without using LiveCycle?

    I have Acrobat Professional X. And I need to read a Microsoft Access Database. I don't have LiveCycle Form. Is there any way that I can connect to my database?

    You are in the wrong forum, mate. This is a forum for ColdFusion.

  • Unable to update or insert into Access database table using OleDB, and it doesn't return any errors.

    I'm new to VS. I have run the following code. It does not produce any error, and it does not add or update data to my Access database table.
    dbUpdate("UPDATE prgSettings SET varValue='test' WHERE varSetting='test'")   
    Function dbUpdate(ByVal _SQLupdate As String) As String
            Dim OleConn As New OleDbConnection(My.Settings.DatabaseConnectionString.ToString)
            Dim oleComm As OleDbCommand
            Dim returnValue As Object
            Dim sqlstring As String = _SQLupdate.ToString
            Try
                OleConn.Open()
                MsgBox(OleConn.State.ToString)
                oleComm = New OleDbCommand(sqlstring, OleConn)
                returnValue = oleComm.ExecuteNonQuery()
            Catch ex As Exception
                ' Error occurred while trying to execute reader
                ' send error message to console (change below line to customize error handling)
                Console.WriteLine(ex.Message)
                Return 0
            End Try
            MsgBox(returnValue)
            Return returnValue
    End Function
    Any suggestions will be appreciated.
    Thanks.

    You code looks pretty good, at a quick glance.  Maybe you can simplify things a bit.
    For Insert, please see these samples.
    http://www.java2s.com/Code/CSharp/Database-ADO.net/Insert.htm
    For Update, please see these samples.
    http://www.java2s.com/Code/CSharp/Database-ADO.net/Update.htm
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.
    Best to keep samples here to VB.NET
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Accessing Long datatypes using JDBC

    Can any body help me how to access long datatypes in JDBC. I need to store large data in String object arround 100000 length string in long. as of now with pstmt.setString(1,String ) i am able to insert 32700 length string only . how can i over come this. ?
    please provide me some code for my problem .
    thanks in advance.......

    Which DB?
    Which DB field type?
    Which JDBC driver?

  • Populating SAP Database table using JDBC adapter

    Hi Folks,
        I have a requirement to populate a SAP database table say ZTABLE using XI. The Model is the table has to be populated through a file which will be processed by SAP XI. Basically this is a File to JDBC scenario. The database used is ORACLE. Kindly provide me some idea to go ahead.

    I tried to place the MS access table in the shared folder of the Application server system but still it seems the table is not being populated.
    did you check the log in your receiver channel? (/people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn)
    The requirement is to update the tables directly as those are the custom tables.
    i would still say that do not update SAP tables directly from XI/ PI.....this is not a standard architecture/ solution....

Maybe you are looking for

  • Migrating data to a "new" setup, questions

    Hi fellow Archers, This is my current setup: Atom+ION board with 3 SATA ports + 1 PCI card with 2 SATA ports. Storage: 2x 2TB 1x 1.5TB 1x 1TB They are all part of the same vg: [root@ion ~]# vgdisplay --- Volume group --- VG Name lvmvolume System ID F

  • Reinstall osx

    My imac was not working properly.  Someone suggested I was having problem with user permissions and I ran disk utility but it didnt help. I created a new user and switched to it and computer works good.  I would like to reinstall my OSX 10.8.3 so tha

  • Best way to connect my iPod to my car stereo?

    My iTrip is a joke. What works best when wanting to connect my iPod directly to my car stereo when I must use the CD changer plug-in behind the stereo?

  • Network Manager fails to detect unsecured network.

    My current laptop uses a clean install of Arch Linux with the latest gnome-shell release. NetworkManager has no problem connecting to the wireless networks at home, but the problem I have is at college. My college has an open wireless network; someti

  • Impdp Stuck

    Database 11.2.0.3 Red Hat Enterprise 6.4 I am running a datapump job and it appears to be stuck. It sits at importing a table constraint. I found this query in another post to check the status: SELECT SUBSTR(sql_text, INSTR(sql_text,'INTO "'),30) tab