SDO_GEOMETRY(cast as BLOB (WKB as a string), SRID)
I have a list of WKB strings. I want to use perl to insert them into a SDO_GEOMETRY column, something like
assuming....
SQL> CREATE TABLE geometries _regions
id NUMBER,
geom SDO_GEOMETRY
a perl version of this.
INSERT into geometries VALUES ( 10000, SDO_GEOMETRY("002340322092348204.....",4326)
Is this possible?
There are sdo_geometry constructors to convert a WKT(CLOB) or a WKB (BLOB) into an SDO_GEOMETRY from WKT and WKB.
sdo_geometry(wkt,srid) or sdo_geometry(wkb,srid).
You have to convert your WKB binary strings into a BLOB before you can use the WKB constructor.
jack
Similar Messages
-
How to cast a BLOB to OrdImage
Hi,
How can I cast or convert a BLOB to OrdImage? For example,
<import...>
public class ConvertBlobToOrdImage {
public static void main(String args[]) throws Exception {
// Load the Oracle JDBC driver:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database:
Connection conn =
DriverManager.getConnection(<"Your database connection">);
conn.setAutoCommit(false);
// Create a Statement:
Statement stmt = conn.createStatement();
String query = "SELECT blob FROM image_t where image_id = 1";
OracleResultSet rset = (OracleResultSet) stmt.executeQuery(query);
rset.next();
OrdImage imageProxy = (OrdImage) rset.getCustomDatum(1, OrdImage.getFactory()); // <-- java.lang.ClassCastException: oracle.sql.BLOB
rset.close();
int height = imageProxy.getHeight();
int width = imageProxy.getWidth();
System.out.println("Image Dimension: " + height + " x " + width);
System.out.println("Image Mime Type: " + imageProxy.getMimeType());
TIA,
Henryxwindy wrote:
Does anyone knows how to cast a HashMap to HashMap<String, Object>?
the session.getAttribute return only a HashMapthere is no way to do this safely
you can use this annotation to suppress unchecked warnings
@SuppressWarnings("unchecked") -
How to save blob data (variable length string) in a customized table?
Dear Friends
I have written a very simple program to update table with 2 fields which
looks as follows.
========================================================
Table name ZTESTBLOBDATA
Field Key Init Data Element Data Type Length
ID Checked ZID NUMC 2
BLOB ZBLOB STRING 0
=========================================================
FOllowing is the sample program that I have written (Transaction SE38).
=========================================================
REPORT ZTESTBLOBPROG
TABLES: ZTESTBLOBDATA
data : itab like ZTESTBLOPDATA occurs 1 with header line.
select * from ztestblobdata into table itab.
ztestblobdata-id = sy-dbcnt +1.
ztestblobdata -blob = 'abcdefghijklmnopqrstuvwxyz.'.
insert ztestblobdata.
=========================================================
When I try to save and activate the program, I get the following
error message
'ztestblopdata' must be a flat structure. You cannot use internal
tables, strings, references, or structures as components.
==========================================================
Using the data type STRING is a must since it is a variable length
data which varies from few characters to few gig.
How can go around this problem.
Any feedback will be highly appreciated.
PS. I have checked old postings on SDN, spoken to my ABAP contacts and also couple of instructors from SAP when I took XI courses but didn't get a satisfactory answers.
Edited by: Ram Prasad on Oct 15, 2008 12:28 PMThanks a lot for the response.
The string that we are getting is from another application via netweaver XI integration and is being sent as a string which has to be saved in an SAP table. I am not sure if IDOC option will suit our needs, but will definitely read more about it.
If there is any other suggestion of feedback I would appreciate it a lot.;
Tks
Ram -
Convert BLOB from database to string
Hi All,
I have retrieved the blob data from my database , and now i have it in my InvokeVariable. The below details will brief the structure of my output variable.
<variable name="Invoke1_RetrieveRecordForInstanceId_OutputVariable"
messageType="*ns1:RetrieveRecordForInstanceIdOutputCollection_msg*"/>
<wsdl:message name="RetrieveRecordForInstanceIdOutputCollection_msg">
<wsdl:part name="RetrieveRecordForInstanceIdOutputCollection" element="db:RetrieveRecordForInstanceIdOutputCollection"/>
</wsdl:message>
<xs:complexType name="RetrieveRecordForInstanceIdOutputCollection">
<xs:sequence>
<xs:element name="RetrieveRecordForInstanceIdOutput" type="RetrieveRecordForInstanceIdOutput" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RetrieveRecordForInstanceIdOutput">
<xs:sequence>
<xs:element name="INSTANCE_ID" type="xs:decimal" nillable="true"/>
<xs:element name="SOURCE_XML" type="xs:base64Binary" nillable="true"/>
<xs:element name="TARGET_XML" type="xs:base64Binary" nillable="true"/>
</xs:sequence>
</xs:complexType>
I make my assign statement like below.
<assign name="Assign2">
<copy>
<from variable="Invoke1_RetrieveRecordForInstanceId_OutputVariable"
part="RetrieveRecordForInstanceIdOutputCollection"
query="/ns2:RetrieveRecordForInstanceIdOutputCollection/ns2:RetrieveRecordForInstanceIdOutput/ns2:SOURCE_XML"/>
<to variable="EnhancedBLOBdata"/>
</copy>
</assign>
I have my java code for converting the blob to string as below.
String input = (String)getVariableData("*EnhancedBLOBdata*");
Base64Decoder baseDecoder= new Base64Decoder();
try {
byte[] decodedBytes = input.getBytes();
String decoded = new String(decodedBytes);
//String decoded = Base64Decoder.decode(input);
setVariableData("DecodedString", decoded);
catch(Exception ex)
ex.printStackTrace();
The data type of EnhancedBLOBdata is base64Binary.. I also checked with 'string' . Even then i dint get the proper decoded form.
Can anyone help me in using the variable SOURCE_XML coming under the RetrieveRecordForInstanceIdOutputCollection, directly in the line,
String input = (String)getVariableData("*Invoke_Output_Variable....<some format>*");
so that there is no need of assigning to some other variable.. Bcz while assignig i am not sure, the assigned variable contains data in blob format.
Kindly help me in this regard.
Thanks,
Sabarisri. NI have figured out the error happens on a data picture with about 700KB of data all of the other data fields have less than 100KB. Is there a way around this size issue.
-
I have an SQL Server function to take a JDEdwards numeric date and convert it to an SQL Date field.
CREATE FUNCTION [dbo].[date_ccyyddd_to_mmddyyyy]
@JulianDate as Numeric(18,0)
RETURNS Date
AS
BEGIN
Declare @ResultDate as Date
Set @ResultDate = DATEADD(YEAR, @JulianDate / 1000 + 1899, Cast('01/01/0001' as Date))
Set @ResultDate = DATEADD(Day, @JulianDate % 1000 -1, @ResultDate)
RETURN @ResultDate
END
In many query based reports we have used the function. It works quite nicely for all but one user. For this one user Crystal is casting the date result as a string, it will then display as a yyyy-mm-dd format instead of his default mm/dd/yyyy short date format. It would generally be ok but since it is typed as a string if the user exports the results to excel it is not recognizing the column as a date either. The strange piece of the equation is that if the user saves the report to the enterprise server and I open it, go to edit the SQL command, do nothing, close the edit box, it gives me the unmapped fields wizard where I can fix the report. Thus when I open or generate a new report with this function it "knows" the result is a date but with a specific user it sees the result as a string.
Has anyone had a similar situation or can lead me in the correct direction to fix this? Unfortunately, this user is our power user, he writes more reports than anyone else. It appeared as a problem when we upgraded from Crystal Enterprise 2008 to 2013.
Current work around for user is to use a crystal CDate() function on the report side but I would like to get the correct solution.
Any assistance appreciated,To add to Dell's suggestion:
If OLE DB then use:
MS SQL 2005 - OLE DB Provider
MS SQL 2008 - SQL Native 10
MS SQL 2012 - SQL Native 11
MS SQL 2013 - SQL Native 11
If ODBC then use:
MS SQL 2005 - SQL Native
MS SQL 2008 - SQL Native 10
MS SQL 2012 - SQL Native 11
MS SQL 2013 - SQL Native 11
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter -
is it possible to interpre or cast a string with "arraysyntax" like "{5,8}" as an array?
or is the only way to parse the string and catch the values via string comparisons? this would mean it doesn't matter how the string looks like as long as i am able to get the values.
probably it is possible via a script engine?
i am using javascript to eval strings like "3+6".(representative = (Double) engine.eval("3.5");)
but evaluating strings like "(1,2,3)" (javascript array syntax) is different?! And array=(double[]) engine.eval("(3.5,1.0)"); would not work?i am can freely specify the string. so it could also 1,2|3,4. but i thought it is some how possible to specify the string the right way and then cast/interpret it directly as a string.
"What does engine.eval("(3.5,1.0)").getClass() return? Are you getting a List of Doubles?"
that is exactly what i want to know -
the correct way for javascript is:
double[][] value = (double[][]) engine.eval("new Array(new Array(1.0,2.0),new Array(3.0,4.0))");i know javascript it self returns "[[1.0,2.0][3.0,4.0]]" but i don't know which class the eval returns. javadoc says object. -
Type cast with String representation
I have a hashtable full of Objects along with a String representation of their type. Is it possible to cast an Object back using a String representation of its type. ie
String str = "helpme";
String type = "String";
str = (Object)str;
now I want to get str back to String type but with using the variable type.Do not crosspost: http://forum.java.sun.com/thread.jsp?thread=355714&forum=4&message=1482427
-
ClassCastException while inserting in oracle.sql.BLOB
Hi,
I have to insert a blob data in to database . I wrote the code . I'm having a ClassCastException problem in the line oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
oracle.sql.BLOB.DURATION_CALL); while trying to store a BLOB value I'm using Oracle 9i. (JDBC classes12.jar).
if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem .
But when I use JBoss to run , I will get ClassCastException
I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the jboss datasource. The code to save the BLOB is as follows:
String sql = " update test set code = ? where id = ? ";
BLOB newBlob = BLOB.createTemporary(dbcon, false, BLOB.DURATION_CALL);
newBlob.putBytes(1,data.getBytes());
stmt = dbcon.prepareStatement(newsql);
stmt.setBlob(1, newBlob);
stmt.setInt(2, Studid );
stmt.executeUpdate();
stmt.close();Can any one tell me how can I get this code to work with the datasource implementation.
ThanksI think this could be a problem with the class loader . Take a look at this thread It should solve your problem.
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=788715 -
Writing to BLOB with getBinaryOutputStream
I'm trying to insert a BLOB and have problems with a variety of the methods listed in documentation.
1) The method that is in the Oracle examples, oracle.sql.BLOB.getBinaryOutputStream(), give me a warning that it is deprecated.
2) In other Oracle documentation, getBinaryOutputStream(long) is specified, but that doesn't exist in my version of oracle.sql.BLOB.
3) Yet other documentation says to use the JDBC 3.0 standard call, which is setBinaryStream(long). However, I get this error when running it: java.lang.AbstractMethodError: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long)
I don't want to use the deprecated method, but that's the only one that works. Any ideas?
Using 10g driver with an 8i database.
thanksIâm not sure how to use PreparedStatement.setBlob(Blob). Seems like the only way to create a BLOB is to SELECT it, and then you still need to call BLOB.setXXX. I tried setBytes(..) but get the same AbstractMethodError as with setBinaryStream(..)
Hereâs the stacktrace from JDev, not sure it has what you're looking for. In this scenario, I use a PreparedStatement to create a blob locator using this:
String CREATE_STATEMENT = "INSERT INTO IWR_FILE " +
"(SA_FILE, SA_IWR, FILE_NAME, FILE_BLOB) VALUES " +
"( ?, ?, ?, empty_blob())";
I then select that record and try to write the blob using:
(imported oracle.sql.BLOB)
ResultSet blobRS = blobPS.executeQuery();
BLOB blob = (BLOB) blobRS.getBlob(1);
OutputStream blobOUT = blob.setBinaryStream(1L);
Tried casting the ResultSet to an OracleResultSet, but still got the error.
com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: java.lang.AbstractMethodError: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long) at IWRFacade_StatelessSessionBeanWrapper0.setDTOList(IWRFacade_StatelessSessionBeanWrapper0.java:621) at iwr.ejb.beans.Tester.testFileDAO(Tester.java:117) at iwr.ejb.beans.Tester.main(Tester.java:47) at mypackage7.InitiatorServlet.init(InitiatorServlet.java:27) at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2094) at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4523) at com.evermind.server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2413) 04/08/30 09:49:04 com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: java.lang.AbstractMethodError: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long); nested exception is:
java.rmi.RemoteException: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long); nested exception is:
java.lang.AbstractMethodError: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:640) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186) at java.lang.Thread.run(Thread.java:534) Nested exception is: java.rmi.RemoteException: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long); nested exception is:
java.lang.AbstractMethodError: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long) at com.evermind.server.ejb.EJBUtils.makeException(EJBUtils.java:941) at IWRFacade_StatelessSessionBeanWrapper0.setDTOList(IWRFacade_StatelessSessionBeanWrapper0.java:621) at iwr.ejb.beans.Tester.testFileDAO(Tester.java:117) at iwr.ejb.beans.Tester.main(Tester.java:47) at mypackage7.InitiatorServlet.init(InitiatorServlet.java:27) at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2094) at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4523) at com.evermind.server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2413) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:640) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186) at java.lang.Thread.run(Thread.java:534) Caused by: java.lang.AbstractMethodError: java.io.OutputStream oracle.sql.BLOB.setBinaryStream(long) at iwr.ejb.dao.FileDAO.getInsertPS(FileDAO.java:244) at iwr.ejb.dao.FileDAO.setDTO(FileDAO.java:90) at iwr.ejb.beans.IWRFacadeBean.setDTOList(IWRFacadeBean.java:102) at IWRFacade_StatelessSessionBeanWrapper0.setDTOList(IWRFacade_StatelessSessionBeanWrapper0.java:564) ... 11 more -
Oracle BLOB problem...pls help if possible
I have been having trouble with my JSP code using the Tomcat server. I've finally gotten the compiler to recognize my result set as an Oracle Result set without it giving me casting errors. Here is part of my code:
%@ page import="oracle.sql.*"%>
<%@ page import="oracle.sql.BLOB"%>
<%@ page import="oracle.jdbc.driver.*"%>
<%@ page import="oracle.jdbc.driver.OracleResultSet"%>
<%@ page import="java.lang.Object.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<body bgcolor="navajowhite">
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Andy","system","pass");
//con.setAutoCommit(false);
Statement myStatement = null;
String sourceDirectory = "D:\\Tomcat\\jakarta-tomcat-4.0.3\\webapps\\Root\\Mproject\\";
String fileName = sourceDirectory + "Test.doc";
String SS = "222-22-2222";
myStatement.executeUpdate("INSERT INTO LI.TEST (ID, FILE_NAME, BLOB_COLUMN)" +
"VALUES(SS,'" + fileName + "',EMPTY_BLOB())");
oracle.jdbc.driver.OracleResultSet blobResultSet =
(oracle.jdbc.driver.OracleResultSet)myStatement.executeQuery(
"select BLOB_COLUMN " +
"from LI.TEST "+
"where FILE_NAME = '" + fileName + "' " +
"FOR UPDATE" );
blobResultSet.next();
oracle.sql.BLOB myBlob;
myBlob = ((oracle.jdbc.driver.OracleResultSet)blobResultSet).getBLOB("BLOB_COLUMN");
int chunkSize = myBlob.getChunkSize();
byte[] byteBuffer = new byte[chunkSize];
File myFile = new File(fileName);
FileInputStream myFileInputStream = new FileInputStream(myFile);
long position = 1;
int bytesRead;
while ((bytesRead = myFileInputStream.read(byteBuffer)) != -1)
myBlob.putBytes(position, byteBuffer);
position += bytesRead;
myFileInputStream.close();
however now, it is still giving me wierd errors. It says that
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Clob getClob(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Clob getClob(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Ref getRef(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Ref getRef(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Blob getBlob(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Array getArray(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Array getArray(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.
package org.apache.jsp;
^
8 errors, 1 warning
can anybody tell me what i'm doing wrong? This is the last hurdle in my project and I would sincerly apprecaite any help. Many thanks
AndrewOK, I'm confused. You declare a statement, set it to null, then try to execute a query with it? Your statement will still be null, you'll get a NullPointerException.
And the OracleResultSet? This object will ONLY be created by using either Oracle's thin driver or OCI driver. The JDBC-ODBC bridge has no idea what an OracleResultSet is. The OracleResultSet IS a ResultSet object so there is no marked error on the cast, but the fit just isn't there. Had this compiled you could expect a ClassCastException at runtime.
If you have to use ODBC, you will not be able to use Oracle-specific database objects. If you have an Oracle database available, then the ODBC driver is going to give you poor performance anyway, use Oracle's thin driver and you'll have access to the objects you're attempting to manipulate.
And, as always, have fun! -
Searching for strings in a txt file
I am writing a program based on the six degrees of seperation theory.
Basically I have been given a (very large) txt file from the imdb with a list of all the films written in it.
The text in the document is written like this:
'Tis Autumn: The Search for Jackie Paris (2006)/Paris, Jackie/Moody, James (IV)/Bogdanovich, Peter/Vera, Billy/Ellison, Harlan/Newman, Barry/Whaley, Frank/Murphy, Mark (X)/Tosches, Nick (I)/Moss, Anne Marie
(Desire) (2006)/Ruggieri, Elio/Micijevic, Irena
.45 (2006)/Dorff, Stephen/Laresca, Vincent/Eddis, Tim/Bergschneider, Conrad/Campbell, Shawn (II)/Macfadyen, Angus/John, Suresh/Munch, Tony/Tyler, Aisha/Augustson, Nola/Greenhalgh, Dawn/Strange, Sarah/Jovovich, Milla/Hawtrey, Kay
10 Items or Less (2006)/Ruiz, Hector Atreyu/Torres, Emiliano (II)/Parsons, Jim (II)/Freeman, Morgan (I)/Pallana, Kumar/Cannavale, Bobby/Nam, Leonardo/Hill, Jonah/Vega, Paz/Echols, Jennifer/Dudek, Anne/Berardi, Alexandra
10 MPH (2006)/Weeks, Hunter/Armstrong, Pat (II)/Caldwell, Josh/Waisman, Alon/Keough, Johnathan F./Weeks, Gannon
10 Tricks (2006)/Cruz, Raymond/Swetland, Paul/Selznick, Albie/Hennings, Sam/Gleason, Richard/Leake, Damien/Skipp, Beth/Ishibashi, Brittany/Thompson, Lea (I)/Jinaro, Jossara/Brink, Molly
1001 Nights (2006)/Wright, Jeffrey (I)
10th & Wolf (2006)/Lee, Tommy (VI)/Renfro, Brad/Ligato, Johnny/De Laurentiis, Igor/Luke Jr., Tony/Mihok, Dash/Garito, Ken/Capodice, John/Dennehy, Brian/Gullion, Jesse/Salvi, Francesco (I)/Cordek, Frank/Marsden, James (I)/Bernard, Aaron/Brennan, Patrick (VII)/O'Rourke, Ben/Gallo, Billy/Heaphy, James/Stragand, Dave/Vellozzi, Sonny/Pistone, Joe (I)/Morse, David (III)/Landis, Pete/Cain, Atticus/Trevelino, Dan/Demme, Larry/Sisto, Frank/Rosenbaum, Paul/Grimaldi, James (I)/Ribisi, Giovanni/Hopper, Dennis/Devon, Tony/Sigismondi, Barry/Kilmer, Val/Marinelli, Sonny/Cacia, Joseph/Rossi, Leo (II)/Tott, Jeffrey/Wawrzyniak, Aaron/Boombotze, Joey/Marie, Corina/Arvie, Michilline/Warren, Lesley Ann/De Laurentiis, Veronica/Moresco, Amanda/Boecker, Margot/Rossi, Rose/Latimore, Meritt/Dunlap, Doreen/Perabo, Piper/Horrell, Nickole/Sonnichsen, Ingrid
11 Minutes Ago (2006)/Irving, Len/Welzbacher, Craig/Michaels, Ian/Dahl, Evan Lee/Gebert, Bob/Juuso, Jeremy/Hope, Trip/Green-Gaber, Renata/Dawn, Turiya/Reneau, Taryn/M
Thats just 2 lines!
what the program will do is take in a name (from a gui) of an actor/actress and find the smallest connection to a famous actor.
So first things first, my idea of thinking is to search the file for K.E.V.I.N. B.A.C.O.N and all his films, and safe them into an array. Then do another search for films from the actor that the user entered at the gui. then find the shortest possible connection to both stars.
my code for the search part of the program
import java.io.FileInputStream;
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;
public class FileSearch {
File aFile = new File("cast.06.txt");
FileInputStream inFile = null;
String actor = "surname, forename"; // the person who will be the centre point e.g. kevin.bacon.
//get the result of the actor from the gui will go here.
public void openFilm()
try
inFile = new FileInputStream(aFile);
catch(FileNotFoundException e)
System.out.println("Error");
}The problem I have is that I can't work out how to search the txt file for a specific string/s and save them into an array. (I'm not sure if this is the best way to go about it or not at this stage).
So whats the best way to search for an actor from that file and save the film title and the year of release?
Hope this makes sense? what I hope the final program will be like is like this http://oracleofbacon.org/I went away and looked at regular expressions and this is what I came up with
public class NameSearch{
public static void main(String[] args)
NameSearch ns = new NameSearch();
ns.runIt();
public void runIt()
java.util.Scanner fileScan = null;
try{
fileScan = new java.util.Scanner(new java.io.File("imdb.txt"));
}catch(java.io.FileNotFoundException e)
e.printStackTrace();
System.exit(0);
String token = null;
String actor = "Surname, Forename";
//real name will go in actor, left it like that for example
while(fileScan.hasNext()){
token = fileScan.next();
Pattern pattern = Pattern.compile(actor);
Matcher m = pattern.matcher(token);
while(m.find())
System.out.println(m.start() + m.end());
}This by any means not finished, I'm just trying to get to grips with regualr expressions. But when I run the program it doesn't return anything, from what I've tried to work out is it should return actor x amount of times they appear in the file. But when I run it nothing comes back (the actors name is in the text file) so I'm not too sure what I'm doing wrong, any suggestion please -
Hi,
I need to cast a data but i don't kow how to do it in ABAP.
Actually, I have a variable typed QUAN (quantity i guess) and i want to concatenate it in a String variable. That's not possible.
The solution i've found is to move the Quan variable to a temporary String variable. I think that's a kind of implicit casting.
Then, including this temporary string variable in the Concatenate instruction is possible.
My question is :
Can I directly cast this data instead of using a temporary variable ?
In Java or VB.NET langauges, we can cast variable like that
(String)my_variable
How to do it in ABAP ?
Thankshi,
You got to use the temporary variable of char type as shown below.
data : v_quant type netpr value '1000.00',
v_char(10).
move v_qunat to v_char.
Regards,
Santosh -
Class Cast Exception in EJB2.0
DEBUG com.pack.ApplSessListener 16 - vattributeAdded : errorencountered,java.lang.ClassCastException: java.lang.String cannot be cast to com.pack1.class1
The task for which i getting this exception is..
We have stateful and stateless methods in one bean,So we moved stateful to other bean and likewise made an entry to web.xml and ejb-jar.xml...
-----------------------------------------------------------ejb-jar------------------------------------------------
<session>
<description>Stateless Example</description>
<ejb-name>Stlgl</ejb-name>
<local-home>com.bidm.misc.ejb.session.ejbeans.StlglHome</local-home>
<local>com.bidm.misc.ejb.session.ejbeans.Stlgl</local>
<ejb-class>com.bidm.misc.ejb.session.ejbeans.StlglBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<session>
<description>Stateful Example</description>
<ejb-name>Stfgl</ejb-name>
<local-home>com.bidm.misc.ejb.session.ejbeans.StfglHome</local-home>
<local>com.bidm.misc.ejb.session.ejbeans.Stfgl</local>
<ejb-class>com.bidm.misc.ejb.session.ejbeans.StfglBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
-----------------------------------------------------------ejb-jar- ends-----------------------------------------------
-----------------------------------------------------------Web.xml------------------------------------------------------
<ejb-local-ref>
<ejb-ref-name>Stlgl</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.bidm.misc.ejb.session.ejbeans.StlglHome</local-home>
<local>com.bidm.misc.ejb.session.ejbeans.Stlgl</local>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>Stfgl</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.bidm.misc.ejb.session.ejbeans.StfglHome</local-home>
<local>com.bidm.misc.ejb.session.ejbeans.Stfgl</local>
</ejb-local-ref>-----------------------------------------------------------Web.xml ends------------------------------------------------------
The code is cracking when multiuser hit particular module in application,In that case i getting error..But For single user its running fine...Any suggestion pzSorry, I wasn't asking you to post the code of the class, that's not very helpful at all. I was asking about code where you cast objects of that to a String or perhaps bind it's values to a String property.
-
Detecting character encoding from BLOB stream... (PLSQL)
I'am looking for a procedure/function which can return me the character encoding of a "text/xml/csv/slk" file stored in BLOB..
For example...
I have 4 files in different encodings (UTF8, Utf8BOM, ISO8859_2, Windows1252)...
With java I'can simply detect the character encoding with JuniversalCharDet (http://code.google.com/p/juniversalchardet/)...
thank youSolved...
On my local PC I have installed Java 1.5.0_00 (because on DB is 1.5.0_10)...
With Jdeveloper I have recompiled source code from:
http://juniversalchardet.googlecode.com/svn/trunk/src/org/mozilla/universalchardet
http://code.google.com/p/juniversalchardet/
After that I have made a JAR file and uploaded it with loadjava to my database...
C:\>loadjava -grant r_inis_prod -force -schema insurance2 -verbose -thin -user username/password@ip:port:sid chardet.jarAfter that I have done a java procedure and PLSQL wrapper example below:
public static String verifyEncoding(BLOB p_blob) {
if (p_blob == null) return "-1";
try
InputStream is = new BufferedInputStream(p_blob.getBinaryStream());
UniversalDetector detector = new UniversalDetector(null);
byte[] buf = new byte[p_blob.getChunkSize()];
int nread;
while ((nread = is.read(buf)) > 0 && !detector.isDone()) {
detector.handleData(buf, 0, nread);
detector.dataEnd();
is.close();
return detector.getDetectedCharset();
catch(Exception ex) {
return "-2";
}as you can see I used -2 for exception and -1 if input blob is null.
then i have made a PLSQL procedure:
function f_preveri_encoding(p_blob in blob) return varchar2 is
language Java name 'Zip.Zip.verifyEncoding(oracle.sql.BLOB) return java.lang.String';After that I have uploaded 2 different txt files in my blob field.. (first one is encoded with UTF-8, second one with WINDOWS-1252)..
example how to call:
declare
l_blob blob;
l_encoding varchar2(100);
begin
select vsebina into l_blob from dok_vsebina_dokumenta_blob where id = 401587359 ;
l_encoding := zip_util.f_preveri_encoding(l_blob);
if l_encoding = 'UTF-8' then
dbms_output.put_line('file is encoded with UTF-8');
elsif l_encoding = 'WINDOWS-1252' then
dbms_output.put_line('file is encoded with WINDOWS-1252');
else
dbms_output.put_line('other enc...');
end if;
end;Now I can get encoding from blob and convert it to database encoding and store datas in CLOB field..
Here you have a chardet.jar file if you need this functionality..
https://docs.google.com/open?id=0B6Z9wNTXyUEeVEk3VGh2cDRYTzg
Edited by: peterv6i.blogspot.com on Nov 29, 2012 1:34 PM
Edited by: peterv6i.blogspot.com on Nov 29, 2012 1:34 PM
Edited by: peterv6i.blogspot.com on Nov 29, 2012 1:38 PM -
Is it possible to serialize a user created object with an oracle.sql.BLOB?
Is this possible? Cause I'm getting a WSDL Exception that the oracle.sql.BLOB is not a java bean. So how do I make it a java bean? What data type should I use?
here is the object that was created.
import java.io.Serializable;
public class DiagramsObj implements Serializable {
private int galleyDiagramId = -1;
oracle.sql.BLOB galleyDiagramBlob = null;
private String galleyName = null;
/** SET THE VALUES TO THE OBJECT */
public void setGalleyDiagramId(int newGalleyDiagramId) {
galleyDiagramId = newGalleyDiagramId;
public int getGalleyDiagramId() {
return galleyDiagramId;
public void setGalleyDiagramBlob(oracle.sql.BLOB newGalleyDiagramBlob) {
galleyDiagramBlob = newGalleyDiagramBlob;
public oracle.sql.BLOB getGalleyDiagramBlob() {
return galleyDiagramBlob;
public void setGalleyName(String newGalleyName) {
galleyName = newGalleyName;
public String getGalleyName() {
return galleyName;
}
Maybe you are looking for
-
BURN - Sourceforge - Not Working on New Macbook Pro
Does anyone have any suggestions for me on getting this to work? I just purchased a new Macbook Pro 2012, and using TDK Double Layer 8.5 gb disks DVDs. I took an mp4 and used their s-ware. It converted it to mpg after I selected VIDEO and NTSC, DVD-
-
In all the examples I've seen the radio buttons align vertically. Is it possible to align then horizontally?
-
Will CS4 work with windows 8?
I have just loaded the 2 discs onto a new PC with Windows 8. The upload seemed to be successful but I cannot access the working screen - the computer has all the folders for Bridge, Encore etc but now "applications"
-
firefox won't run
-
How can I get ipconfig /setclassid running through a logon script on Vista.
I have written a number of logon scripts to execute variations of this command at logon but it seems that it will not run for some users and they see a message "The requested operation requires elevation" Is there a way I can call this command at log