XML database query through Java

Hi all.
I am collecting information about a little application i am trying to build:
I have an XML database with records divided in a lot of subdirectory (with three or four .xml files);
directories' names are defined by date in format "yyyymmdd",
the file within are "date_something.xml":
what is the best way to access it by a web app or a java class to search all the dirs adn print results in a readable way (aka not in cmd) ? I need first to define a period of time to search and then some attribute or node to print referred to some element.
I was guessing to use xpath, anyway I ve tryed JSP but it is too difficult and the query i have to do are really simple to build a full servlet.
I am learning xalan through servlet and I think in future this will be my choice but now i need to collect the data by queries without any automation, just to have results for researching and paper writing.
The main problem I found is to search a full series of directory, with transformations i can find out stuff from a single file, but how to do it for a system of directories?
Any suggestion or link to resource would be good also.

lm00 wrote:
ProjectMoon wrote:
By XML database do you mean an actual XML native database, or just a bunch of XML files in a directory structure? If it is an actual XML native database, you should probably use the XML:DB API. If they are just flat files you will need to probably make something that is able to navigate through your directory structure to the documents you want. Once you have that, you can then use XQuery or XPath to get information from those documents.The data is a bunch of directories named by date in format "yyyymmdd", inside each of these there are three or four files .xml
All files have data definitions and schemas but i dont think they are a 'database'. What do u mean "something to navigate through"? A class? Suppose I would like to do it as a webapp what should i have to do?
Yes, I basically meant a class. Before querying the XML file you need something that will retrieve its location. If it's by date you could probably concoct something that takes a Date object and returns a set of File objects. Internally it would traverse the directory trees and find the proper XML file(s).
>>
If you have a LOT of XML documents I honestly recommend something like the eXist XML Native Database, or another XND. I have been playing with them lately and they are very useful.in this case what i have to do? Take the data and put it into a database by this tool? And then I should acces it by a JSP? There is a program using Xpath instead?Well, yes. You would put the files in the XND. Although I don't know if that's useful or not in your situation. It all depends. I also think you're a bit confused as to what JSPs and XPath are...
JSPs are just Java Server Pages, which get dynamically compiled into servlets. If you are following the MVC pattern for servlets/JSP (which you should), JSPs represent your views while servlets are the controllers. The model would be your XML data in this case. XPath is a way to get at that data. If it was in an XND, you could just throw an XQuery/XPath expression at the database and it would give you back XML documents/fragments representing the results of your query. You don't have to make your own system to find the XML documents. Of course, you do have to learn how to use an XND.
Perhaps you should separate what you are trying to do. You have two problems: 1) how to get the XML data you need. 2) How to present it. You should separate those two completely and learn how to do both before attempting to put it together.
Edited by: ProjectMoon on Oct 21, 2009 12:05 PM

Similar Messages

  • Database query from Java

    I'm writing a Java program that needs to query a Microsoft Access database. I'm not sure how to do this. Someone said to use ODBC drivers but I don't know what these are. Any clarification/ideas would be appreciated.

    There are a few easy step to set up a connection to your database in your java program.
    1. establish an odbc data source in windows control panel (may be under Administrative tools).
    2. you need to import the java.sql package.
    3. you need a connection, so type the following into your database class:
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection("jdbc:odbc:/*your data source name goes here*/");
    catch (ClassNotFoundException exception)
    System.err.println("Failed to load JDBC/ODBC driver");
    exception.printStackTrace();
    System.exit(1);
    catch (SQLException exception)
    System.err.println("Unable to connect");
    exception.printStackTrace();
    System.exit(1);
    }4. Find an SQL tutorial on the web.
    5. For each query/update etc create a Statement object using the following code:
    try
    Statement statement = connection.createStatement();
    /* now use the remainder of this try block to execute your query. Each database query returns a ResultSet object */
    ResultSet resultSet = statement.executeQuery("/*your query string goes here*/");
    /* the next() method in ResultSet returns true if there are any more records, like an iterator. Therefore, you know if there are any results or not*/
    if (resultSet.next())
    /* If your query was a 'SELECT * FROM ...etc' then you will get a whole row from the table(s) within the database. if you need to extract a number from that record and you know the column number, then use the following */
    int id = resultSet.getInt(1);
    /* where 1 corresponds to the first column in the table, and so on. Ifyou want to extract a String, the use the getString() method*/
    catch (SQLException exception)
    }That's basically the easiest way to go about it (I think). Best to consult a book for a more in-depth look. Try Java - How to Program, by Deitel and Deitel (available at www.deitel.com). I found this very useful.

  • SAP database updations through Java program

    Hi All,
    From Java program, I want to access SAP database batch RFC
    Please tell me which batch RFC's I have to use for read and update of a table.
    Please also tell me how to find out a batch RFC for a particular table.Is there any way to find it out like BAPI.
    What are the steps and settings ?
    Detailed steps help the requirement.
    Thanks,
    Giri

    Giri,
    Ya...Java APP sents data to XI and XI needs to insert the data into the database.
    Before the next round of data is sent by the Application, Xi should sent back info on the status of the records.
    Is this what you want?
    This will be like I have pointed earlier possible without a BPM. But, make the call from the sending application Synchronous. And then map the JDBC response to the calling aplication.
    But this updation is only possible through XI.
    If i got the requirement wrong can you let me know in more detail, what is it that you are trying?
    Reward if solved

  • Frequent Database Access through  Java Mapping ?

    I have to implement a Java Mapping Program which will require frequent database Access to compare and read table data from some other  data base .
    What is the most optimum procedure to  implement it ?
    Should i make a jdbc  call every time from the code or should i use EJB(Session beans + Entity beans)...
    or  any other process besides these 2 to acheive maximum performance
    Please Suggest
    regards
    Nilesh Taunk.

    Hi Nilesh,
    I would suggest you to use XI DB Lookup API's for accessing Database.  Eventhough it will not give you maximum performance, it will be very easy to change the configuration parameters in JDBC Adapter (No need for hardcoding user id/password/Driver details etc.) and you can refer the same in your  Lookup API's.
    Please refer the link: <a href="/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler Weblog</a>
    Regards,
    Ananth

  • XML data source from Java application

    Hello everyone,
    I want to use BI Publisher reports from my Java application.
    1. I have generated xml from database query in Java application.
    2. I have created BIP template sampleReport.rtf
    3. I need to generate PDF report using sampleReport.rtf and generated xml data source.
    How this (step 3) can be achieved using BI publisher web service? If someone has sample code, this would be great.
    Thanks.

    Hello everyone,
    I want to use BI Publisher reports from my Java application.
    1. I have generated xml from database query in Java application.
    2. I have created BIP template sampleReport.rtf
    3. I need to generate PDF report using sampleReport.rtf and generated xml data source.
    How this (step 3) can be achieved using BI publisher web service? If someone has sample code, this would be great.
    Thanks.

  • Database query results

    I have made a database query:
    try{
    java.lang.Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=DriverManager.getConnection("jdbc:oracle:abc@abc","login","pwd");
    HashMap params=new HashMap();
    q=new Query("CORE_SYSTEM/TRN_SHORD_DESC",true);
    dbr=q.executeQuery(params,con);
    taQueryOut.setText(""+q);
    taQueryOut.append(""+dbr);
    }catch(Exception e){
    e.printStackTrace();
    } // end try-catch
    The code is not important, it works.
    What methods are there for me to use for printing out the number of results returned etc. A link to a reference material would be handy too. Note that the database used is Oracle, so if there are any ora-specific functions available, good.

    This is the technique that I use to count rows:
    Quick trick that I use is
    1. make sure that your Statement is type_scroll_insensitive:
    connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);2. move your cursor to the last row(after executing your query)
    resultset.last();3. get the row number:
    int numberOfRows = resultset.getRow(); /*returns the number of rows*/4. set the cursor back to the beginning:
    resultset.beforeFirst();5. ready to process the rows as usual.
    This technique has a drawback though:
    a scrollable resultset has less performance than non-scrollable
    hope this might help,
    Jamie

  • Request parameter are not stored in database through Java Bean

    Hi,
    I want to store the request parameter in database through Java Bean.Allthough program are properly run but value are not store in DB.
    Here My code:
    Login.html:<html>
    <head>
    <title>A simple JSP application</title>
    <head>
    <body>
    <form method="get" action="submit.jsp" >
    Name: <input type="text" name="User">
    Password: <input type="password" name="Pass">
    <input type="Submit" value="Submit">
    </form>
    </body>
    </html>SimpleBean.java:
    package co;
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.*;
    public class SimpleBean implements java.io.Serializable{
    private String User="";
    private String Pass="";
    public SimpleBean(){}
    public String getUser() {
    return User;
    public void setUser(String User) {
    this.User = User;
    public String getPass() {
    return Pass;
    public void setPass(String Pass) {
    this.Pass = Pass;
    public void show()
         try
    System.out.println("Printed*************************************************************");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("Loading....");
    Connection con=DriverManager.getConnection("jdbc:odbc:Ex11dump");
    System.out.println("Connected....");
    PreparedStatement st=con.prepareStatement("insert into Table1 values(?,?)");
    System.out.println("~~~~~~~~~~~~~~~~~~~~");
    String User=getUser();
    st.setString(1,User);
    String Pass=getPass();
    st.setString(2,Pass);
    int y= st.executeUpdate();
    System.out.println(y);
    System.out.println("Query Executed");
    con.commit();
    con.close();
    System.out.println("Your logging is saved in DB *****************");
    catch(Exception e)
    e.printStackTrace();
    }submit.jsp:
    <jsp:useBean id="obj" class="co.SimpleBean"/>
    <jsp:setProperty name="obj" property="*" />
    <jsp:getProperty name="obj" property="User" /> <br>
    <jsp:getProperty name="obj" property="Pass" /> <br>
    <% obj.show();%>
    <%
    out.println("Ur data is saved in DB");
    %>Please Help me.
    Thanks.

    The issue is in the naming of your fields.
    Change User -> user and Pass->pass
    Name: <input type="text" name="user">
    Password: <input type="password" name="pass">

  • Syntax for Database query on a simple java appl?

    Connection con;
    private boolean conFree = true;
    private String dbName = "java:comp/env/jdbc/gene";
    public geneDB () throws Exception {
    try{
         Context ic = new InitialContext();
         DataSource ds = (DataSource) ic.lookup(dbName);
    con = ds.getConnection();
    catch (Exception ex){
    throw new Exception("Couldn't open connection to database: " + ex.getMessage());
    String insertStatement =     "insert into gene (cds,status) values(" + cds + "," + status + ")";
    PreparedStatement prepStmt = con.prepareStatement(insertStatement);
    prepStmt.setString(1, cds);
    prepStmt.setString(2, status);
    prepStmt.executeUpdate();
    prepStmt.close();
    Any comments??? This is what i have done, pls comment....

    actually i m having some kind of trouble and i would like to confirm about the code design suggestion regarding about the database query using pointbase through a java web service.

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • Generate an xml file from Database query results

    Hi, can anyone help me out with this problem I'm having. What are the steps in creating an xml file directly from the results of a database query. I currently have a very simply process that queries a database via a partner link. The query returns the data but it's from this point that I am stuck. I need to create an xml file with the data along with the xml tags. I've looked at dozens of tutorials with no luck.
    I would greatly appreciate help with this.
    bpel rookie

    Should be quite simple.
    Create another partnerlink, configure it to use the file adapter, and write to an XML file. In this case you need to create an XML Schema (.xsd) of the file you want to create.
    Before you write to the file, either add assign steps to copy individual attributes or use a transform activity to convert from the database format to the file (xml) format.

  • Access database query resultset in java scriptlet

    Question:
    1) I am Creating a web page and plotting points on the page:
    2) Database query results in decimal values dec_latitude and dec_longiitude.
    3) Perform calculations on lati. & long. in a java scriptlet to create a plot position (xpos, ypos).
    4) Send the xpos and ypos back to the java server page
    5) Use <IMG and absolute positioning to plot the point at position xpos, and ypos.
    6) Repeat until all rows in the query result set have been plotted.
    I don't know how to pass the dec_latitude and dec_longitude to the java scriptlet.
    After the java scriptlet calculation translates the latitude and longitude
    into xpos and ypos, I need to pass the xpos and ypos back to the java server page so that a data point is plotted on a map at position xpos, ypos.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    The code below results in a runtime error.
    Am I supposed to create a java object and access that in the java scriptlet? Can the java scriptlet access the latvar and longvar created during the "<c:set var="latvar"... ?
    If not, what mechanisum do I use to access the resulting colums: dec_latitude and dec_longitude? I need the java scriptlet to convert the
    dec_latitude and dec_longitude into a display position based on the number of pixels from the TOP and LEFT (xpos, ypos). Then plot of the data point using the IMG and (xpos, ypos). This will overlay a map whose z-index is lower than the plotted data point.
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar"); <--- runtime error !!!!
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    </c:forEach>

    Thanks
    I still get a runtime error: I translated the code you gave to code below .... which I think is equivalent. See Below: I'm still learning about this stuff so I may not have not translated this properly. Do
    you see what I am doing wrong?
    Best Regards,
    - John
    %@ page language="java" contentType="text/html;
    charset=ISO-8859-1"%>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ page import="java.lang.Math"%>
    <sql:setDataSource dataSource="jdbc/SampleDB" />
    <c:set var="genus_name" value="${param.genus_name}" />
    <c:set var="species_name" value="${param.species_name}" />
    <c:set var="species_common_name" value="${param.species_common_name}" />
    <c:set var="dd_sighted" value="${param.dd_sighted}" />
    <c:set var="mm_sighted" value="${param.mm_sighted}" />
    <c:set var="yyyy_sighted" value="${param.yyyy_sighted}" />
    <c:set var="species_state" value="${param.species_state}" />
    <c:set var="species_county" value="${param.species_county}" />
    <c:set var="species_country" value="${param.species_country}" />
    <c:set var="dec_latitude" value="${param.dec_latitude}" />
    <c:set var="dec_longitude" value="${param.dec_longitude}" />
    <c:set var="notes" value="${param.notes}" />
    <c:set var="person_first_name" value="${param.person_first_name}" />
    <c:set var="person_last_name" value="${param.person_last_name}" />
    <c:set var="person_street" value="${param.person_street}" />
    <c:set var="person_city" value="${param.person_city}" />
    <c:set var="person_state" value="${param.person_state}" />
    <c:set var="person_zip" value="${param.person_zip}" />
    <c:set var="person_country" value="${param.person_country}" />
    <c:set var="person_email" value="${param.person_email}" />
    <h2>Species Sightings:</h2>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Breckenridge Citizen Bio-Survey Selective Output Page</title>
    </head>
    <body>
    Izaak Walton League of America
    <h1>Breckenridge Citizen Bio-Survey Selective Output</h1>
    <HR>
    <c:if test="${param.action == 'Submit'}">
    <%int xpos = 0;
         int ypos = 0;
         float latitude = 0.0F;
         float longitude = 0.0F;
         float latitudeMpls = 45.06F;
         float longitudeMpls = -93.14F;                    int xposMpls = 1205 - (int) Math.round(latitudeMpls);
         int yposMpls = 735 + (int) Math.round(longitudeMpls);
    %>
    <IMG SRC="minnesota_1990.jpg" ALT="minesota map" style="z-index:1;"> <----- THIS WORKS FINE
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2"> <----- THIS WORKS FINE FOR HARDCODED MPLS XPOS AND YPOS
    <sql:query var="qryBio">
    SELECT
    PERSON_FIRST_NAME,
    PERSON_LAST_NAME,
    GENUS_NAME,
    SPECIES_NAME,
    SPECIES_COMMON_NAME,
    SPECIES_COUNTY,
    SPECIES_STATE,
    SPECIES_COUNTRY,
    DD_SIGHTED,
    MM_SIGHTED,
    YYYY_SIGHTED,
    DEC_LATITUDE,
    DEC_LONGITUDE,
    NOTES,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    genus_name like rtrim(upper('${genus_name}')) AND
    species_name like rtrim(upper('${species_name}')) AND
    species_common_name like rtrim(upper
    ('${species_common_name}')) AND
    species_state like rtrim(upper('${species_state}')) AND
    species_county like rtrim(upper('${species_county}')) AND
    species_country like rtrim(upper('${species_country}')) AND
    person_first_name like rtrim(upper('${person_first_name}')) AND
    person_last_name like rtrim(upper('${person_last_name}')) AND
    person_email like rtrim(upper('${person_email}'))
    </sql:query>
    <c:forEach var="row" items="${qryBio.rows}">
    <--- THE LINE ABOVE WORKS FINE --->
    <c:set var="latvar" value="${row.dec_latitude}" scope="page" />
    <c:set var="longvar" value="${row.dec_longitude} " scope="page" />
    <%
    latitude =
    Float.parseFloat((String)pageContext.getAttribute("latvar"));
    <--- RUNTIME ERROR OCCURS HERE --- SEE LINE ABOVE --->
    longitude =
    Float.parseFloat((String)pageContext.getAttribute("longvar"));
    xpos = (int) Math.round(latitude);
    ypos = (int) Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    request.setAttribute("xpos",new Integer(xpos));
    request.setAttribute("ypos",new Integer(ypos));
    %>
    IIMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    <--- THIS (ABOVE) WORKS FINE WITH CORRECT VALUES FOR XPOS AND YPOS WHEN RUNTIME ERROR DOES NOT OCCUR --->
    </c:forEach>
    </c:if>

  • Class not found Exception when accessing database through java using ASP

    I am trying to access the database through ASP via java:
    the database is setup as a system database..
    the java class works fine if i try to run it as a stand alone.. but as soon as I run it through ASP.. it does not get passed the driver line.. is there anything in particular I need to do ?
    JAVA and ASP and the output code looks like as follows:
    java code looks like this:
    import java.sql.*;
    public class testDB{
    private Connection connection;
    private Statement statement;
    public static void main(String[] args){
    public String getDriver(){
    String x = "start of program ";     
    try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              x = x + " Got Driver";
              connection = java.sql.DriverManager.getConnection("jdbc:odbc:database", "sunny", "jassal");
              x = x + " After connection statement";
              statement = connection.createStatement();
              x = x + " After statement statement";
              statement.execute("Insert into name (name, age) values ('hello', 33)");
              x = x + " after insert";
              connection.close();
         } catch (Exception sqlex){x = x + sqlex.getMessage() + " " ;
              x = x + sqlex.toString() + " " ;
              x = x + sqlex.getLocalizedMessage();}
    return x;
    and the asp looks like this:
    <html>
    <%
         set javaobject = GetObject("java:testDB")
         response.write "after getting object"
         response.write javaobject.getDriver()
         set javaobject = nothing
    %>
    </html>
    after getting objectstart of program sun/jdbc/odbc/JdbcOdbcDriver java.lang.ClassNotFoundException: sun/jdbc/odbc/JdbcOdbcDriver sun/jdbc/odbc/JdbcOdbcDriver

    what would I set the classpath to be .. and I am sorry I am new to this.. but how would I be able to check the CLASSPATH .. or even how do I set the CLASSPATH.. to which directory would i need to set the classpath to
    I know I can set the classpath in dos by set CLASSPATH=
    but I dont know how to set it so it would read the drivers

  • Access database query data in Java SCriptlet

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar");
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar");
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

  • Java.lang.NoClassDefFoundError: oracle/xml/sql/query/OracleXMLQuery

    Hello, all.
    I get this error message:
    java.lang.NoClassDefFoundError: oracle/xml/sql/query/OracleXMLQuery
    at oracle.xml.xsql.actions.XSQLQueryHandler.handleAction(Compiled Code) ...
    when trying to view an xsql page with the jswdk 1.0.1 web server. (I have no problems when using Web-to-go)
    Classpath includes:
    C:\jdk1.1.8\lib\classes.zip;
    C:\xsql\lib\oraclexsql.jar;
    C:\xsql\lib\xmlparserv2.jar;
    C:\xsql\lib\xsu111.jar;
    C:\xsql\lib\classes111.zip;
    C:\xsql\lib;
    What could be the problem?
    Mateja
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Muench ([email protected]):
    Only thing I can think of is that maybe your server classpath is getting too long. I recall one of the Java Web Server releases having a classpath length limit that caused strange errors like this because that .jar files you thought were on your classpath were getting their path names truncated so the Java VM cannot find the JAR's.
    Try putting xsu111.jar earlier in the list of JAR's and/or try shortening the classpath (perhaps by using SUBST'd drive letters or softlinks on Unix to shorten the path names).<HR></BLOCKQUOTE>
    Putting the xsu11.jar file towards the start of the path did not help.
    I have rewriten the entire bat file that creates the CLASSPATH and starts the server and things now seem to work. There must have been some error in the original bat file, that I just couldn't see.
    Anyway - I thank you for your help.
    null

  • How to create an Oracle DATABASE through Java Programming Language.. ?

    How to create an Oracle DATABASE through Java Programming Language.. ?

    Oracle database administrators tend to be control freaks, especially in financial institutions where security is paramount.
    In general, they will supply you with a database, but require you to supply all the DDL scripts to create tables, indexes, views etc.
    So a certain amount of manual installation will always be required.
    Typically you would supply the SQL scripts, and a detailled installation document too.
    regards,
    Owen

Maybe you are looking for