How do you query Oracle RDF database using Java program?
Does anyone know how to get data out of the oracle RDF database using Java?
I'm running the following java code and it returns basically null values. My guess is that the get_triple() function returns a dataset other than resultset. I've tried searching the Oracle web site. Am I supposed to be using CLOB object? Any help would be appreciated. Thanks
sql = "SELECT a.triple.GET_TRIPLE() AS triple FROM family_rdf_data a";
ResultSet rs = stmt.executeQuery( sql ) ;
while ( rs.next() )
System.out.println( rs.getString(1) ) ;
rs.close() ;
get_triple() returns an object, and the code would be different from the code of retrieving a string. Some sample code for retrieving objects is at http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.html
get_subject(), get_property() return strings so the code below should work. get_object() returns a CLOB so different handling would be required and there is some sample code at the link above.
Melli
Similar Messages
-
How to display a oracle table from a java program?
How to display a oracle table from a java program.
Hello friends, I have written a Java program, using oracle 10g as backend.
I want to display a oracle table as output. Im not getting how to display oracle table as a output table.. Pls help me
Thank youjayanthds, you're not going to get a satisfactory
answer to this here. it's too big a task to justbe
quickly outlined in a forum - the reply "all youneed
to do is to query you table and return it asJTable"
is worthless, for example, since the solution to
any problem can be distilled to such a
soundbite, if need be. doesn't make the solutionany
simpler
essentially you're asking "how do I write adatabase
application?". all you'll get is snippets of code
that, when fitted together, will eventually helpyou
do this, but you'll spend days and days comingback
saying "right, I've done that, now what?" until
either you or the forum gets frustrated with the
whole affair and the process stops
there are entire books written about this subject,
and countless tutorials and guides on theinternet.
you're better off going down that routehehehe.well, it's true! I used to have a manager that would outline the solution to a problem in a few lines of pseudocode, and then firmly believe that the actual solution would be just as brief and simple. shame his pseudocode included such lofty abstractions as "reformat all data" -
How to extract .sit files(in MAC) using java program
Hi,
please help me , i want to simple program for
" how to extract .sit files(in MAC) using java program"
that sit files same as zip files in windows..[Thanks for reply...
but i search in the google about this topic...there is no results will appear..
the problem is "i have to run program in the MacOS like extract all the
.sit(StuffIt) extension files. These sit files same as zip files in the windows... we have one tool called StuffIt Expander but it is 3rd party tool. but here requirement is i have to write my own program to extract all the files same as zip file program...
please do the needful..i am waiting for ur reply,,, -
How to create a directory or Folder using java program?
Hi all,
Can any one know, how to create a directory(new folder) in java.
can any give me some idea, on creating a directory using java program dynamically.
thanx in advancehi thanks for your answer,
sorry, actual i know this technique(its my fault i didnt mentioned it)
i am looking for some what different technique.
bye
ram -
How to get comparable Oracle JDBC performance using Java 1.4 vs 1.1.7?
Our application makes extensive use of JDBC to access an Oracle database. We wrote it a number of years ago using java 1.1.7 and we have been unable to move to new versions of java because of the performance degradation.
I traced the problem to JDBC calls. I can reproduce the problem using a simple program that simply connects to the database, executes a simple query and then reads the data. The same program running under java 1.4 is about 60% slower than under java 1.1.7. The query is about 80% slower and getting the data is about 150% slower!
The program is attached below. Note, I run the steps twice as the first time the times are much larger which I attribute to java doing some initializations. So the second set of values I think are more representative of the actual performance in our application where there are numerous accesses to the database. Specifically, I focus on step 4 which is the execute query command and step 5 which is the data retrieval step. The table being read has 4 columns with 170 tuples in it.
Here are the timings I get when I run this on a Sparc Ultra 5 running
SunOs 5.8 using an Oracle database running 8.1.7:
java 1.1.7 java 1.4
overall: 2.1s 3.5s
step 1: 30 200
step 2: 886 2009
step 3: 2 2
step 4: 9 17
step 5: 122 187
step 6: 1 1
step 1: 0 0
step 2: 203 161
step 3: 0 1
step 4: 8 15 <- 87% slower
step 5: 48 117 <- 143% slower
step 6: 1 2I find the same poor performance from java versions 1.2 and 1.3.
I tried using DataDirect's type 4 JDBC driver which gives a little better performance but overall it is still much slower than using java 1.1.7.
Why do the newer versions of java have such poor performance when using JDBC?
What can be done so that we can have performance similar to java 1.1.7
using java 1.4?
========================================================================
import java.util.*;
import java.io.*;
import java.sql.*;
public class test12 {
public static void main(String args[]) {
try {
long time1 = System.currentTimeMillis();
/* step 1 */ DriverManager.registerDriver(
new oracle.jdbc.driver.OracleDriver());
long time2 = System.currentTimeMillis();
/* step 2 */ Connection conn = DriverManager.getConnection (
"jdbc:oracle:thin:@dbserver1:1521:db1","user1","passwd1");
long time3 = System.currentTimeMillis();
/* step 3 */ Statement stmt = conn.createStatement();
long time4 = System.currentTimeMillis();
/* step 4 */ ResultSet rs = stmt.executeQuery("select * from table1");
long time5 = System.currentTimeMillis();
/* step 5 */ while( rs.next() ) {
int message_num = rs.getInt(1);
String message = rs.getString(2);
long time6 = System.currentTimeMillis();
/* step 6 */ rs.close(); stmt.close();
long time7 = System.currentTimeMillis();
System.out.println("step 1: " + (time2 - time1) );
System.out.println("step 2: " + (time3 - time2) );
System.out.println("step 3: " + (time4 - time3) );
System.out.println("step 4: " + (time5 - time4) );
System.out.println("step 5: " + (time6 - time5) );
System.out.println("step 6: " + (time7 - time6) );
System.out.flush();
} catch ( Exception e ) {
System.out.println( "got exception: " + e.getMessage() );
... repeat the same 6 steps again...
}If I run my sample program with the -server option, it
takes a lot longer (6.8s vs 3.5s).Which has to be expected, as the -server option optimizes for long running programs - so it shoudl go with my second suggestion, more below...
I am not certain what you mean by "just let the jvm
running". Our users issue a command (in Unix) which
invokes one of our java programs to access or update
data in a database. I think what you are suggesting
would require that I rewrite our application to have a
java program always running on the users workstation
and to also rewrite our
commands (over a hundred) to some how pass data and
receive data with this new server java program. That
does not seem a very reasonable just to move to a new
version of java. Or are you suggesting something
else?No I was just suggestion what you descript. But if this is not an option, then maybe you should merge your java-programs to C or another native language. Or you could try the IBM-JDK with the -faststart (or similar) option. If thew Unix you mention is AIX, then there would be the option of a resetable-vm. But I cannot say if this VM would solve your problem. Java is definitly not good for applications which only issue some unqiue commands because the hotspot-compiler can not be efficiently used there. You can only try to get 1.1.7 performance by experimenting with vm-parameters (execute java -X). -
How can I connect to a database using Java Web Start?
When I run the application without Java Web Start, the program can get the driver and connect to the database. However, when I try to use this same application with Java Web Start, the program can not load the driver. Why is this happening? I am using a mySql database driver.
I assume you are trying to connect using JDBC, are did you include the jdbc jar in your resources ?
-
How do you query the iTunes database by genre?
I am trying to enumerate music tracks from the iTunes database by genre.
I am able to get genre id's from the query
http://itunes.apple.com/WebObjects/MZStoreServices.woa/ws/genres
The description is here:
http://www.apple.com/itunes/affiliates/resources/documentation/genre-mapping.htm l
I can retrieve urls to tracks with something like this
https://itunes.apple.com/search?term=R+B/Soul&limit=2
However the search term applies to all fields and I get a mixed collection of results, many of them are wrong.
I would like to enumerate songs from a specific genre, but I can't figure out how.
I've tried multiple ways of using the "genreIndex" attribute, but I keep getting 0 results.
For example I would like to enumerate the first 10 Techno songs. Techno has a genre id=1050
https://itunes.apple.com/search?term= any ideas??
Thanks, EdHi there are mappings for the reference fields from AP and AR, so you can buid up the links there. Just look at the reference fields of gl_je_lines and try to identify which is valuable for you.
Ugur YILMAZ
http://oracle-master.com -
How do you generate uml diagrams And decoding java programs
1)Hi i have neatbeans 5.0 i have finished witting my code and i wanted to know if there is a way to generate uml diagrams straight from the code.
2) Also i think i have bought a java programme to improve your memory and i wanted to know is there a way you look in the java sorce code so i can change the settings the file has a dynamic.dll(application extension), a level(dat File) and a unins000(dat file)Darryl.Burke wrote:
Also i think i have bought a java programme to improve your memory
Did you remember to install it?I don't think his memory goes back that far :) -
To get JRE or JDK version using Java Programs
How do get JRE or JDK version using Java Programs?.
Kindly Reply...
By
ManiIf you're talking about current program's runtime environment (as opposed to all installed JDK/JRE) : System properties
-
How To Store pdf or doc file in Oracle Database using Java Jdbc?
can any one help me out How To Store pdf or doc file in Oracle Database using Java Jdbc in JSP/Serlet? i tried like anything. using blob also i tried. but i am able 2 store images in DB not files. please if u know or else if u have some code like this plz send that to me, and help me out plz. i need that urgent.
Hi.. i am not getting error, But i am not getting the original contents from my file. i am getting all ASCII vales, instead of my original data. here i am including my code.
for Adding PDF in DB i used image.jsp
Database table structure (table name. pictures )
Name Null? Type
ID NOT NULL NUMBER(11)
IMAGE BLOB
<%@ page language="java" import="java.util.*,java.sql.*,java.io.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
PreparedStatement ps,pstmt,psmnt;
ps = con.prepareStatement("INSERT INTO pictures VALUES(?,?)");
File file =
new File("D:/info.pdf");
FileInputStream fs = new FileInputStream(file);
ps.setInt(1,4);
ps.setBinaryStream(2,fs,fs.available());
int i = ps.executeUpdate();
if(i!=0){
out.println("<h2>PDF inserted successfully");
else{
out.println("<h2>Problem in image insertion");
catch(Exception e){
out.println("<h2>Failed Due To "+e);
%>
O/P: PDF inserted successfully
i tried to display that pdf using servlet. i am giving the code below.
import java.io.IOException;
import java.sql.*;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DispPDF extends HttpServlet {
* The doGet method of the servlet. <br>
* This method is called when a form has its tag value method equals to get.
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//response.setContentType("text/html"); i commented. coz we cant use response two times.
//PrintWriter out = response.getWriter();
try{
InputStream sPdf;
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
PreparedStatement ps,pstmt,psmnt;
psmnt = con.prepareStatement("SELECT image FROM pictures WHERE id = ?");
psmnt.setString(1, "4"); // here integer number '4' is image id from the table.
ResultSet rs = psmnt.executeQuery();
if(rs.next()) {
byte[] bytearray = new byte[1048576];
//out.println(bytearray);
int size=0;
sPdf = rs.getBinaryStream(1);
response.reset();
response.setContentType("application/pdf");
while((size=sPdf.read(bytearray))!= -1 ){
//out.println(size);
response.getOutputStream().write(bytearray,0,size);
catch(Exception e){
System.out.println("Failed Due To "+e);
//out.println("<h2>Failed Due To "+e);
//out.close();
OP
PDF-1.4 %âãÏÓ 2 0 obj <>stream x+är á26S°00SIá2PÐ5´1ôÝ BÒ¸4Ü2KüsSSS4C²ê Pkø$VãGÒU×713CkW )(Ü endstream endobj 4 0 obj <>>>/MediaBox[0 0 595 842]>> endobj 1 0 obj <> endobj 3 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj xref 0 7 0000000000 65535 f 0000000325 00000 n 0000000015 00000 n 0000000413 00000 n 0000000168 00000 n 0000000464 00000 n 0000000509 00000 n trailer <<01b2fa8b70ac262bfa939cc786f8770c>]/Root 5 0 R/Size 7/Info 6 0 R>> startxref 641 %%EOF
plz help me out. -
BLOB insertion in Oracle 10g database using ojdbc14 (10g drivers)
Hello!
I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
<u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
following issue fixed in SP3.
<b>CR124933</b>
<b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
the connection was available for reassignment.
Code was added to ensure the BLOB is completely processed before closing the pool connection or
ending the transaction.</b>
I believe the problem arises when we try to insert BLOB into database using a refreshed connection
from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
But this still continues to behave intermittently.
We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
export WLS_CLASSPATH
CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
export CLASSPATH
After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
Following is the stack trace of the errors that I recieve:
<Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
"MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
Please let me know if there is anything that I am missing.
Thanks
Pradeep Gpradeep g wrote:
Hello!
I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
> <u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
following issue fixed in SP3.
> <b>CR124933</b>
<b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
the connection was available for reassignment.
Code was added to ensure the BLOB is completely processed before closing the pool connection or
ending the transaction.</b>
> I believe the problem arises when we try to insert BLOB into database using a refreshed connection
from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
But this still continues to behave intermittently.
We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
> WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
export WLS_CLASSPATH
CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
export CLASSPATH
> After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
> Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
> Following is the stack trace of the errors that I recieve:
> <Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
"MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
<Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
Please let me know if there is anything that I am missing.
> Thanks
> Pradeep GHi. This is something we'd like to diagnose. How is your application
getting using and closing pool connections? The initial symptom
seems to be an internal oracle problem... Are you using standard
JDBC or oracle-specific calls?
Joe -
How to start or shut down database using sql developer in windows
Dear Sir/Madam,
how we start or shut down database using sql developer in windows
we are using oracle 11g release2, unix, java & oracle oracle weblogic administration
Thanks & Regards
Manish Kumar
Datbase Team
TCS Ltd.HI, Welcome to OTN form,
SHUTDOWN is not a SQL statement but a SQL*Plus command . You cannot use SHUTDOWN in PL/SQL.
Check following link:
http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve042.htm#i2699551
More Information please check OTN discussion: https://forums.oracle.com/thread/2349159
Thank you -
TES 6.1.x - how do you tell what DB is used by ClientMgr?
We just externalized the Client Mgr DB to Oracle, updated config files, etc. How do you tell what db is using - Derby or Oracle?
After you externalize the CM database, you should see the db objects (tables and views) in the database are now created shortly after you start the CM service.
You can verify creation of database objects in the actual database and in the plugin log upon start-up. This log can be found under the ../ClientManager/plugin/tes-6.0/log directory
John -
How we can create Oracle 9i Database through Commands.
How we can create Oracle 9i Database through Commands.
We need step by step process and all the scripts.CREATE DATABASE
Caution:
This statement prepares a database for initial use and erases any data currently in the specified files. Use this statement only when you understand its ramifications.
Note Regarding Security Enhancements:
In this release of Oracle and in subsequent releases, several enhancements are being made to ensure the security of default database user accounts.
To provide guidance for configuring Oracle9i in a secure manner, Oracle Corporation provides a security checklist. Oracle Corporation recommends that you read this checklist and configure your database accordingly. The security checklist can be found at the following URL:
http://otn.oracle.com/deploy/security/oracle9i/pdf/9iR2_checklist.pdf
Examples
Creating a Database: Example
The following statement creates a database and fully specifies each argument:
CREATE DATABASE sample
CONTROLFILE REUSE
LOGFILE
GROUP 1 ('diskx:log1.log', 'disky:log1.log') SIZE 50K,
GROUP 2 ('diskx:log2.log', 'disky:log2.log') SIZE 50K
MAXLOGFILES 5
MAXLOGHISTORY 100
MAXDATAFILES 10
MAXINSTANCES 2
ARCHIVELOG
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE
'disk1:df1.dbf' AUTOEXTEND ON,
'disk2:df2.dbf' AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE temp_ts
UNDO TABLESPACE undo_ts
SET TIME_ZONE = '+02:00';
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_55a.htm#SQLRF01204
Joel P�rez -
How to create sql database using java frame or appelet?
hi ! i am working on database project i want to create a database using java frame or applet where it asks user to select the location for database to be created , after user have specified the path then the programs creates the database, again i want that database to be read and write by another frame or applet but as user select the path how do i make the connectivity. i just have basic knowledge on java. please give me idea how can i process further.
thanks a lotWhile duffymo is correct in regard to most major database products, it's my understanding (warning! wild-ass guess coming) that the Hypersonic DB is more "application-centric" and the dynamic creation of databases is part of its design. It's pure Java database software, and therefore is not appropriate for all database projects, in particular those that require extremely high-performance.
See http://hsqldb.org/
I've not used it yet (but soon though), and I can't really advise anyone about it.
However, I'm wondering if you phrased you question in a way that is confusing us. To most of us in casual conversation, a "database" is both (1) a large organized collection of data and (2) the software that is used to organize and access it. However, the phrase "create a database" usually means creating a (1) database (a collection of data) using an already created (2) database software, such as Oracle, MySQL, DB2, HSQDB, etc., etc. If you'r question is, how do a create some new database software using Java, the answer is that this is a very very big and hard thing to do for the general case and probably not something you want to be doing.
Maybe you are looking for
-
trying to format my mini hard drive, but my disk utility does not have ms dos option - need to be able to transfer files mac to windows. any ideas? the hard drive is Diamond Digital Mobile Storage 4GB MD100, N623, made by www.Mitsubishi Electric.com.
-
Release startegy for service PO
Hi, Can you people help me out with release startegy for Service PO and service entry sheet? Regards, Satyendra
-
trying to import a cd and songs are being downloaded from an older cd with a similar name
-
PL/SQL procedure for database activity monitoring
Can anyone help me in writing a procedure which will help me in monitoring the database, i.e. if anybody changes something inside a table say add, update or delete then this procedure will tell me about every operation on that table??
-
Is there a way to see how many http requests are handled by a weblogic server over a period of time? I have a system that has about 500 users and it would be useful to know how many requests are made per minute. It would also be nice to know how many