Reading data from MS SQL 2005

This is how you retreive data from database. The file is in
c:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\qsample\WEB-INF\classes\mypackage\
package mypackage; import java.sql.*; import java.util.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Izbazepod5 extends HttpServlet{     public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {     String xtext = request.getParameter("xtext1");     response.setContentType("text/html");     ServletOutputStream out = response.getOutputStream();     out.println("<html>");     out.println("<head>");     out.println("<title>slanje i obrada parametara</title>");     out.println("</head>");     out.println("<body>"); ////////////////////////////////////////////////////////////////////////////////////////////     if(xtext == null ){ out.println("<h1>unesi grad - enter a city </h1> following cities are in database London , Portland , Madrid , Nantes "); out.println("<form action='Izbazepod5' method='post'>"); out.println("<input type='text' name='xtext1'/>"); out.println("</textarea>"); out.println("<br/>"); out.println("<input type='submit' value='posalji'>"); out.println("</form>");     }     else {     out.println("<h1>unesi grad - enter a city </h1> following cities are in database London , Portland , Madrid , Nantes "); out.println("<form action='Izbazepod5' method='post'>"); out.println("<input type='text' name='xtext1'/>"); out.println("</textarea>"); out.println("<br/>"); out.println("<input type='submit' value='posalji'>"); out.println("</form>");     /////////////////////     Connection dbConn = null;     String data = "jdbc:odbc:kasql";         try{             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");             dbConn = DriverManager.getConnection(data,"","");             CallableStatement cstmt = dbConn.prepareCall("{call sve1(?,?,?)}");             //cstmt.setInt(1,Integer.parseInt(xtext));             cstmt.setString(1,xtext);             cstmt.registerOutParameter(2, Types.VARCHAR);             cstmt.registerOutParameter(3, Types.VARCHAR);             ResultSet rec = cstmt.executeQuery();             out.println("<table border='1'>");             out.println("<tr><td><strong>dobavljc - supplier</strong></td> <td><strong>Contact</strong></td></tr>");             while(rec.next()){               out.println("<tr><td>"+rec.getString(1)+"</td> <td>"+rec.getString(2)+"</td></tr>");           }             out.println("</table>");             dbConn.close();                 out.println("</body>");                 out.println("</html>");         }         catch(Exception e){             out.println(e.toString());         }     ////////////////////     }     ///////////////////////////////////////////////////////////////////////////////////////////   }     public void doPost(HttpServletRequest request, HttpServletResponse response)       throws IOException, ServletException {     doGet(request, response);                 }  }
the config file is at
c:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\qsample\WEB-INF\
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"     version="2.4">     <display-name>Hello, World Application</display-name>     <description> This is a simple web application with a source code organization based on the recommendations of the Application Developer's Guide.     </description>     <servlet>         <servlet-name>DynamicImage</servlet-name>         <servlet-class>mypackage.DynamicImage</servlet-class>     </servlet>     <servlet>         <servlet-name>Izbazepod5</servlet-name>         <servlet-class>mypackage.Izbazepod5</servlet-class>     </servlet>     <servlet-mapping>         <servlet-name>DynamicImage</servlet-name>         <url-pattern>/DynamicImage</url-pattern>     </servlet-mapping>     <servlet-mapping>         <servlet-name>Izbazepod5</servlet-name>         <url-pattern>/Izbazepod5</url-pattern>     </servlet-mapping> </web-app>
Edited by: JackWalters on Jul 19, 2008 1:48 PM

Along this horrible piece of code I don't see a question or problem description. Please elaborate about the actual problem.

Similar Messages

  • Reading Data from a SQL table to a Logical file on R/3 appl. Server

    Hi All,
    We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
    I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
    I am new to ABAP , please let me know the steps to be done to acheive this .
    Regards
    - Ajay

    Hi,
    You can find lot of information about Datasets in SCN just SEARCH once.
    You can check the code snippet for understanding
    DATA:
    BEGIN OF fs,
      carrid TYPE s_carr_id,
      connid TYPE s_conn_id,
    END OF fs.
    DATA:
      itab    LIKE
              TABLE OF fs,
      w_file  TYPE char255 VALUE 'FILE',
      w_file2 TYPE char255 VALUE 'FILE2'.
    SELECT carrid connid FROM spfli INTO TABLE itab.
    OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                            " Server to write data
    LOOP AT itab INTO fs.
      TRANSFER fs TO w_file. "" Writing the data into the Application server file
    ENDLOOP.
    CLOSE DATASET w_file.
    OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                          " server to read data
    FREE itab.
    DO.
      READ DATASET w_file INTO fs.
      IF sy-subrc EQ 0.
        APPEND fs TO itab.
        OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
                                                           " application server
        TRANSFER fs TO w_file2.
        CLOSE DATASET w_file2.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    Regards
    Sarves

  • Reading data from Sybase SQL Anywhere 7 database to write into a SQL Server database

    Hi,
    I need to import data from a Sybase SQL Anywhere vers. 7 database. This RDBMS was used more 10-12 years ago. I want to write Sybase data into a SQL Server 2008 R2-2012 database. For testing purposes I'm using SQL Server 2005.
    After that I've installed Sybase SQL Anywhere vers. 7 I can use the Adaptive Anywhere 7.0 ODBC. I'd like to use SSIS to import Sybase data, but I cannot create an OLE DB connection in a right manner while I can create and ODBC connection manager and so I
    can use an Execute SQL task (and not a data flow task, unfortunately!).
    Well, after using this Execute SQL task to read fe a table with thousands of data rows how can I write the entire data collection on a SQL Server table?
    Thanks

    Below link may be helpful,
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/184c937a-2b2c-4e59-b4d7-e8d3d1b476b3/net-provider-for-oledb-sybase-adaptive-server-anywhere-ole-db-provider-90-cant-be-located-when?forum=sqlintegrationservices
    http://supun-biz.blogspot.in/2010/11/extracting-data-from-sybase-sql.html
    Regards, RSingh

  • Why some columns are not read into Power Pivot when reading data from a SQL query

    I have this SQL query that I want to use to read data to PowerPivot from:
    SELECT Score.FieldCount as fieldcount, Score.Record.GetAt(0) as predicted_gender, Score.Record.GetAt(1) as probability_of_gender,  Score.Record.GetAt(2)
    as probability_of_m,  
    Score.Record.GetAt(3) as probability_of_f,  Score.Record.GetAt(4) as customerkey
    FROM 
    SELECT * FROM dbo.myCLR1(
    dbo.MyCLR2('c:\fILES\MLSM.xml'), 
    'SELECT * FROM [dbo].[Customer]') Input
    ) Score
    After I click 'Finish' in "Table Import Wizard", I can only get 1 column (FieldCount) in Power Pivot window. Why don't I get the other 4 columns? If I save the result to a table I do get all columns but my goal is to dynamically present the result
    so that's not an option. Can anyone shed some light?
    Thanks,
    Chu
    -- Predict everything. http://www.predixionsoftware.com

    If I only pass in query as 
    SELECT * FROM dbo.myCLR1(
    dbo.MyCLR2('c:\fILES\MLSM.xml'), 
    'SELECT * FROM [dbo].[Customer]') Input
    I do get 2 columns (FieldCount and Record as shown below)
    -- Predict everything. http://www.predixionsoftware.com

  • Can 2008 reporting services read data from 2012 sql server

    Will 2008 SSRS be able to retrieve data / speak
    to 2012 SQL Server database?

    I will try and see if it throws error. Check below similar thread.
    https://social.technet.microsoft.com/Forums/en-US/067406f5-bd65-40eb-b333-3449adeefade/connect-to-sql-server-2012-databases-from-ssrs-2008-r2?forum=sqlreportingservices
    Regards,
    Vishal Patel
    Blog: http://vspatel.co.uk
    Site: http://lehrity.com

  • Using forms6i and reading data from MS SQL server 7

    Hi!
    I have been given a new task to connect to Microsoft SQL SERVER 7 with Oracle 6/6i development with ODBC and extract specific data.
    I am realy stuck with this I hope some one will help me with this as soon as possible.
    thanka

    I did a similar thing with developer 2000 (Form 4.5) and SQL server6.5.
    There are lots of things involved and there will be issues that need to be resolved in you application but you can take one thing at a time and you should be able to do it.
    -First make sure that your SQL server is up and running.
    -Then make a client machine that connects to SQL server.
    -On the client install your Form6 or 6i.
    -Install ODBC manager on your Client Machine.
    -Get the Oracle ODBC driver for SQL server.
    -There is a document available with developer 2000 for open data source. It should be with your Form6/6i documentation. It has got a section for connection with SQL server.
    Start with this and where ever you get stuck ask away question on the forum.
    Hope this help

  • Help Required -- Can we use SQL Query to READ data from SAP MDM Tables

    Hi All,
    Please help.........
    Can we use SQL Query to READ(No Creation/Updation/Deletion  just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
    Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
    Thanks in Advance
    Regards

    All the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
    Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
    But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
    BR,
    Alok

  • Hi experts, how to use open sql to read data from one " maintenance view"?

    i want to use this part of data within report ,so how to use open sql statement to read data from one " maintenance view"?

    Hi
    You can't use OPEN SQl statements to fetch data from maintenance view
    You have to use only Database views
    see the different types of views and the difference
    The followings are different types of views:
    - Database View (SE11)
    Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.
    In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.
    - Help View ( SE54)
    Help views are used to output additional information when the online help system is called.
    When the F4 button is pressed for a screen field, a check is first made on whether a matchcode is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view.
    - Projection View
    Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.
    A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.
    - Maintenance View ( SE54 )
    Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
    Please have a look at below link. It will help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed06446011d189700000e8322d00/frameset.htm
    for more detailed info look on:
    http://www.sap-img.com/abap/what-is-the-different-types-and-usage-of-views.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abap+dictionary&
    Reward points for useful Answers
    Regards
    Anji

  • Read data from SharePoint using ABAP sql command

    We need to read data from a SharePoint site and update the sap object services with the information. There is a lot of information on how to put data into Sharepoint from SAP, but we need to get data from SharePoint and put it into SAP. Is it possible to retrieve data from SharePoint using sql command in ABAP program? If it is possible, what do we need to do to have SAP recognize where to get the SharePoint data?
    Richard Newman

    Hi Newman,
    You can use native sql in your abap code to read data from SharePoint's database. But I would suggest you to generate a SharePoint webservice which can provide you the neccessary data so that you can consume this webservice in ABAP
    (Will be quite faster than native sql).
    Regards,
    Ozcan.

  • SQL Server 2012 64 bit - reading data from dbf (DBase 3/4/5 or VFoxPro) - solution and examples

    It took me quite a while to find a solution that will enable me to read dbf files from 64 bit SQL server, so i decided to create this guide for all of you guys searching for an answer.
    Download and install Access Database Engine 64 bit : http://www.microsoft.com/en-us/download/details.aspx?id=13255
    Creating Linked server for me is the most elegant solution 
    To create a Linked Server modify following sql statement with your data and execute it:
    EXEC master.dbo.sp_addlinkedserver 
    @server = N'DBFServer', 
    @srvproduct=N'', 
    @provider=N'Microsoft.ACE.OLEDB.12.0', 
    @datasrc=N'D:\DBF\', 
    @provstr=N'dBASE IV'
    You can read data directly without linked server, but i find this less elegant
    To read data directly modify following sql statement with your data and execute it:
    Use KTCDB
    GO
    sp_configure 'show advanced options', 1
    reconfigure 
    GO
    sp_configure 'Ad Hoc Distributed Queries', 1 
    reconfigure
    GO
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1;
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1;
    SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                           'dBASE IV;Database=D:\DBF\;', 
                           'SELECT * FROM ODMRAD')
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 0;
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 0;
    GO
    sp_configure 'Ad Hoc Distributed Queries', 0
    reconfigure
    GO
    sp_configure 'show advanced options', 0
    reconfigure 
    GO
    I hope this will help you guys avoid frustration and wasting lots of time.

    Visakh, i believe you are mixing terms 'reading' and 'importing', as with solution i proposed you can consume 'live' data without the need to
    import it on every change.
    To clarify : Data in DBF's can change at any point in time, and with my solution whenever you try to read data from either linked server or directly, you will always have most recent data, contrary to the import methods where you are cloning data and actually
    could run into many problems synchronizing original and cloned data.
    Ok..I understand that
    Based on your data volatility you can configure an automated job for executing SSIS package to extract latest of data from dbase. But again it wont be "in real time". There will be slight delay depending on frequency you choose for job.
    I was suggesting it more from a datawarehousing perspective whether data refresh happens only after predefined period (daily,6hrs etc)
    If requirement is to get realtime data when you desire then definitely linked server would be the way to go.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Reading Data from SQL Server 2000 Linked Servers

    Hello,
    I have a colleague who wants to read data from a OO4O driver Linked Server my FRENCH_FRANCE.US7ASCII Oracle 8i database.
    He's got some troubles to read data with "é", "à", and so on. They always replaced by "?"
    Since I have ask him to use SQL Developer on his server to see if he has got configuration problems, his PL/SQL queries return "square figure" characters (not the usual "²") instead of "?".
    For info, I've said it to use CONVERT(column, 'FR8DEC', 'US7ASCII) but it doesn't work too (also try with 'UTF8' or 'WE8MSWIN1252')
    Is there a way with the SQL Server collation ???
    How can I solve his problem ???

    The select query returns the following infos :
    PARAMETER VALUE
    NLS_CHARACTERSET US7ASCII
    NLS_NCHAR_CHARACTERSET US7ASCII
    My colleague uses the 10.2.0.1.0 client with ODAC 10.2.0.2.20.
    His SQL Server linked server is 2000 with the SQL_Latin1_General_CP437_BIN (he tried the use of the distant NLS_LANG option and the no set the NLS_LANG too with no results).
    Thanks in advance,
    Yours,
    Mickaël

  • Database Toolkit: Reading data from SQL database

    Hello,
    I have been working on a automated test system storing data into a SQL server database.  Once you get your head wrapped around the toolkit and walk through some of the examples it is not too bad.  Writing to the database was very straight forward.  I simply put all of my data including the primary keys into a cluster and inserted the cluster into the specified table.  As I learned the hard way,  it is very important for all of your types to match up.  I saved double type from labview as decimal type in the SQL database, and long integer in labview as integer in the SQL database. 
    For the the read VI, this is where my questions lie. After establishing a connection reference I used the "DB Tools Create Parameterized Query" VI combined with a SQL statement to find the recordset that I was looking for.  I used a standard SQL statement using the primary keys such as, "Select * From TableName Where Measurements = "%Measurements%" ".  This VI creates a command reference which I then passed to multiple "DB Tools Get Parameter Value" VIs.  I could not get this to work with the command reference. 
    I then switched over to the "DB Tools Execute Query" inputting the same SQL statement I had used before.  THis VI passed a recordset reference, which I then passed to a "DB Tools Get Properties" VI to check if the database was empty or not.  I then passed the recordset reference to multiple "DB Tools Fetch Element Data"  VI's to read the data from the SQL database.  THis worked very well. 
    therefore I am wondering:
    What is the difference between a command reference and a recordset reference in the Database connectivity toolkit? 
    Why would one work and not the other? 
    Is there ever a case when you would want to use one method over the other? 
    I have asked my app guys and Labview training instructor different database type questions, and I not received a decent answer to date.
    Thanks,
    Jackson

    Hello,
    Can you pass the command reference to a single "DB Tools Get Parameter Value" VI?  What exactly do you mean when you say you couldn't get this to work with command references... can you post an error message or the results?  The documented difference is that they are different flavors of ADOs (activeX data objects), one is a command and the other is a recordset reference.  I know this does not draw a precise distinction, but I'd like to understand this problem fully so we can find one!
    Please repost with anything more you can give!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Can SharePoint 2010 read data from an external SQL Server 2012 data Source?

    Hi,
     I would like to Know whether SharePoint can read the data from a SQL server 2012 external data source?
    I am not talking about SharePoint internal database. I need to get the data from an sql database which is used by some other application. For My SharePoint server I am using SQL 2008 R2 as an internal database engine. But I need to get some other data from
    another data Source which is configured in SQL server 2012.  Can any one help me on this whether is there any problem on accessing the data from SQL 2012. If there is no problem for that, please provide me the version of SQL data source compatible with
    SharePoint 2010 and SP 2010 sp1. 
    Thanks!
    Regards,
    Henoy 

    Hi Romeo ,
    I have already visited this page. But there is no answer for my question. I just want to know whether we
    can done the same from a SQL 2012 server.
    Please help me to know whether SharePoint 2010 is Compatible to get the data from SQL 2012 external data source.
    Thanks for your instant reply.
    Regards,
    Henoy TM.
    +919035752610

  • Use evdre to query data from a SQL View

    Hi all
    I believe that it is possible to use evdre to query data from a SQL View. If this is possible then how does one go about setting it up in the evdre options (assuming that the view has already been created)?
    Regards,
    Byron

    Byron,  perhaps this is no longer supported, it might be worth opening up a case at service.sap.com on this.  However, I did find the following on Page 11 of the "Usages and Considerations of EVDRE" pdf file.  This doc is imbedded in the helpfile for BPC 7 SP5 (which was released in August of 2009, well after note 1315011 was last updated.
    It looks like you are limited to one custom view per application, since you have to name the view in a parameter at the APPLICATION level.  Go into BPC Administration, login to the application related to the custom view, choose "Set Application Parameters" and enter the name of the view to the Application Parameter called "EVDRE_QUERYVIEWNAME"  If it is not listed, go ahead and create it at the bottom of the Application parameter screen.
    Also:  I interpreted the following info from Page 10 of the same doc:
    In your EVDRE, set the following options:
    QueryEngine: MANUAL
    QueryType:  enter either NEXJ  OR TUPLE  see below:
    NEXJ  - Use two-dimensional queries using the nonemptycrossjoin function
    TUPLE  - Use two-dimensional queries using tuples"
    And I'm assuming you'd enter a Y for the following two parameters:
    QueryViewName
    "..to enforce the query engine to use a used-defined SQL view of the fact tables, when trying to read the values using SQL queries. This option is typically used in conjunction with the SQLOnly option (see below). "
    Option SQLOnly
    "..to enforce the query engine to only execute SQL queries, when reading data. This can be achieved using this option."

  • Read data from excel sheet and then perform the required operations.

    Hi all
    I need to write a procedure which can read data from excel sheet.I have excel sheet in which i have to options one is modification and other is addition.so if it reads modification then i need to read the concerned table name then check its availability in pl-sql datbase.If table exists then reading the realated column in that row to fire the querry. The excel sheet is saved in local disk c.
    can anybody help me with this.How i need to start specialy to read the data from excel sheet saved in local disk c.
    Edited by: user13334062 on Jun 30, 2010 3:45 AM

    Hi
    If you can convert the excel to a csv format, then it can be simply query from DB Creating Oracle External Tables. Best part is that you may still change the CSV using EXCEL.
    Following action Points can be adopt;
    *1. Convert Excel File to a csv. File Save as CSV*
    *2. Create Oracle Directory* ( This has to be the location of your excel file )
    SQL> Create directory mydir as 'C:\testdb'; --- "testdb" is the location folder in win for your excel sheet.
    *3. Create the External Table*
    SQL> create table my_ext_tab (
    Field1 Datatype,
    Field2 Datatype,
    Field3 Datatype,
    Field4 Datatype,
    Field5 Datatype
    Organization external
    (type oracle_loader default directory mydir
    access parameters (records delimited by newline fields terminated by ',')
    location ('my_ext_tab.csv'))
    reject limit 100;
    *4. Now you can query the table "my_ext_tab"*
    Select * from "my_ext_tab";
    Please avoid the reformat the data column inside the spreadsheet (CSV).

Maybe you are looking for

  • Server 2012 Hyper-V locks up Virtual Server for no reason.

    Server 2012 Hyper-V locks up virtual servers for no reason. This is a production server. I began building this server in February. I installed the server in November. 2012 server R1 is full of bugs! First who was the rocket scientist that decided tha

  • Indesign cs6, export interactive pdf

    When i export my interactive document to pdf, the result is not working well. All the roll over buttons are blinking when the mouse cursor point on it. also i have problem with layers. the appearance of layers is not as same as file, so some images g

  • Finder Tags In Time Capsule?

    I have some files on my Time Capsule (purchased in 2014) that I would like to use the coloured Finder Tags on. I can tag the files so they have the coloured dot next to them but when I search for the files via the tags they don't appear, only the fil

  • Using Classes and Methods

    Hi Experts, I am studying ABAP Objects, before that I need to know How to use the exsiting classes and Methods in our program and how to search for particular class and methods? If it explanied with example well and good. Thanks sai

  • Is it Possible to Create a Role Owner Group in CUP

    Currently has a workflow that has each role owner to approve a role request.  Would like to create to have two differenct role owners to have to  approve the same role but with these to role owners want to have one of the role owners to have two peop