SQL Queries changes from Java 6 beta2 to Java6 RC
Hi All,
I was using new classes and annotations for database access, like java.sql.BaseQuery, java.sql.Select in Java 6 beta2.
I've just upgraded to Java 6 RC and...oops these classes cannot be found? What is changed? How can I refactor my application?
Thanks in advance,
Antonio
there's nothing about that in the release notes...
google result's on sun's site are 404...
bad luck
Similar Messages
-
How to send a Varying Array param to a PL/SQL Stored Procedure from Java
* I am VERY new to jdbc, and even somewhat new to Java
* I'm using Java 1.5, Oracle 10g.
* I need to call the following PL/SQL Stored Procedure from Java:
procedure setEventStatus
i_deQueueStatus in deQueueStatus_type
*deQueueStatus_type is the following (an array of deQueueStatus_OBJ):
CREATE OR REPLACE TYPE deQueueStatus_OBJ as object
eventID number (20),
dequeuestatus varchar2(20)
CREATE OR REPLACE TYPE deQueueStatus_TYPE IS VARYING ARRAY(500) of deQueueStatus_obj
*I have created a Java object as follows:
public class EventQueueDeQueueStatus
long eventID;
String dequeueStatus;
EventQueueDeQueueStatus(long eventID, String dequeueStatus)
this.eventID = eventID;
this.dequeueStatus = dequeueStatus;
I have an ArrayList of these.
I need to pass this list to the Stored Procedure. How do I create a java.sql.Array so I can call CallableStatement.setArray to set the parameter? Or do I use something else? I have tried setObject with both the ArrayList and also with a primitive array, but got "Invalid Column Type" both times.
Any help would be greatly appreciated. I just got this task today, and I have to make it work by Tuesday :-( !
Thanks,
KathyKathy,
Search the archives of this forum and the JDBC forum for the terms STRUCT and ARRAY and you can find some sample code on the JDBC How-To Documents page and the JDBC Samples which can both be accessed from this page:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
Good Luck,
Avi. -
Running a SQL*Plus command from Java
I have a requirement to run SQL* Plus commands from Java. The results as they would appear in SQL*Plus window or spool file should be captured and stored in a table.
For example,
SQL> select * from dual;
D
X
1 row selected;
SQL>
All the lines above should be stored for later use.
Could any one give pointers?
Thanks,
Ravi<p>
Hi,
</p>
<p>
<strong><font face="Courier New">
public class RuntimeExecApp {
public static void main(String args[]) throws IOException
Runtime r = Runtime.getRuntime();
r.exec("C:\\Oracle\\sqlplus.exe");
}</font></strong>
</p>
<p>
Kuba
</p>
Message was edited by:
KUBA -
Domain Change from Java to SAP
Hi,
I am having 7+ years of Exp in Java, J2EE and weblogic portal dev. currently I am looking for technology change and interested in SAP.
Can you please suggest me what would be the best option to learn in SAP, I heard about EP and XI components, which will be the best for Java exp guy like me? Please guide me for starting a new carrier and to survive in SAP.
Thanks,
KumarbabuHi Maxim,
please try this:
This should be in the Instanceprofile:
SAPFQDN = sap.domain.ru
SAPLOCALHOSTFULL = $(SAPLOCALHOST).$(SAPFQDN)
icm/host_name_full = $(SAPLOCALHOST).$(SAPFQDN)
Best regards
Willi Eimler -
Help!! how to call pl/sql anonymous block from java?
I know that jdbc can call a pl/sql package or procedure,but if i
want to call a pl/sql anonymous block, how can i do it? no procedure
name or package name will be offered.
Can u give me a sample code? thanks very muchthanks ,but do u make sure that it can work? i have tried to do like this ,but i can not get it. Or please give me a detail code, thanks very much
-
I am planning to have career change from JAVA to SAP
I am having 4+ yrs experience in JAVA.Now i thought of shifting to SAP.
Is it apt to shift to SAP?If yes which module is recommended in SAP.Kalpana,
You're in luck. SAP has it's own JAVA programming environment. Your programming skills are directly transferable. You just need to take a class on SAP's programming environment and get certified. See the link below to see the courses offered
https://training3.sap.com/us/en/curriculum/nw_java_dev_na-development-associateprofessional-java-with-sap-netweaver-70-g-en
There's a more detailed curriculum at the following link, but it's probably overkill
https://training3.sap.com/us/en/curriculum/java_na-java-programming-courses-g-en
The links above are for the US, but the classes/information should be the same in India. The only problem is that in India, you have to go through a authorized training center and they're going to want you to pay for all of the training up front. Also, they're probably going to want to run you through the ABAP programming curriculum first, which you don't need if you're happy being a JAVA programmer.
Hope that helps!
Best regards,
--Tom -
Make java.sql.Blob object from java serialized object
I have an ImageIcon which I get from an applet. It gets passed to a servlet. Now, I want to turn the ImageIcon into a blob object so that I can insert it into a database (as/400). How do I do that?
Hi there,
NORMALLY this is a 2-step process:
1.) Convert the ImageIcon into a byte-array
2.) Write the byte-array into the database/blob
For step 1 (this code is 'freehand'):
=====================================
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.write(myImageIcon);
oos.close();
byte[] data = bos.getBytes();
For step 2:
============
This is often database specific, but normally you select a column of a record for update, get the blob-object from the resultset and start writing bytes to it.
BUTTTTTTTT Consider this alternate approach: Assuming the image that is being sent is always small in size, you may simply chose to base-64 encode it and store the resultant string in a varchar column. When you read it back, base-64 decode it. Although the encoding/decoding may appear to be an overhead, I'll bet you it's much faster than blob-level access, both for reads and writes. It's also portable (code-wise) and you can update images through a simple UPDATE statement. In fact, if your database supports it, you could even have a default value for the column (a default image)... -
Calling PL/Sql Stored Procedure from java file
Having problem in calling oracle stored procedure using bc4j.
in ApplicationModuleImpl you can use following e.g.
on client side use a custom method to access
try {
DBTransaction dBTransaction = getDBTransaction();
String stmt = "CALL CHANGE_OWNER( ?, ?)";
CallableStatement callableStatement = dBTransaction.createCallableStatement(stmt,DBTransaction.DEFAULT);
callableStatement.setString( 1, oldOwner );
callableStatement.setString( 2, newOwner );
callableStatement.execute();
} catch (SQLException ex) {
throw new JboException(ex);
} -
Performing sql queries in java without using java libraries
i wonder whether its possible to perform sql queries beginning from create table to updating queries without using the java sql library.
has anyone written such code.You could use JNI to talk to a native driver like the Oracle OCI driver. Doing this is either exiting or asking for trouble depending on your attitude to lots of low level bugs.
-
Logging sql queries without any changes in existing apps
Hi!
Is it possible to log all SQL queries send from application to database via JDBC without any (or really small) changes in code of existing applications?
I'm new to JDBC so any suggestions/ideas/best practices are welcome ;)
Best regards.
Edited by: matthew_ on Mar 16, 2008 5:35 PMIs it possible to log all SQL queries send from application to database via JDBCFirst is an assumption that the driver does in fact sends SQL. It might send some other form.
But excluding that and excluding that the driver explicitly sends it then you can create a proxy driver. You implement the driver to pass everything to the real driver. Along the way it collects the information.
You will find that that is quite bit of work. However it impacts the actual code very little and requires nothing more than loading the driver and changing the connection string in the code where it is used. -
Want to execute SQL Queries from Textfile
I have a text file full of a bunch of sql queries, of the format:
select something1, something2
from someplace
select something3, something4
from someplace2
select something5, something6
from someplace3
I want to execute these queries one at a time and then after each one executes, I will do something with the resultset. Question is, how do I pull each query from the text file one at a time and execute? I was doing this by using java.util.Scanner and java.lang.StringBuilder where I would scan one line at a time and then check to see if the line is empty, otherwise I append the line to the StringBuilder. If the line is empty, I process whatever is stored in the StringBuilder. The problem with doing this is that it does not preserve the newline from the text file, so I get queries that look like:
"select something5, something6from someplace3"
which of course are invalid. Does anyone know a better way to build SQL queries / statements from a text file? How do I get the newline or carriage return character?Just replace newline by space?
-
How to Call SQL Loader from Java ( servlet )?
We need to call SQL Loader command from Java Servlets? Any suggestions how this can be done?
Thanks
RahulProbably not the best way, but you could try using JNI to call a C function which then invokes SQL Loader via system() or exec(). I haven't done this myself though...
-
SQL Queries in Code V/s Stored Procedures
Hi Friend,
Can any one of you guide me with following..
What is faster ? using SQL Queries in Java code or using Stored Procedures which are called from code?
I understnd Stroed Procedures are faster and definitely it provides more maintainability.
If any one can give me any links or resources which outlines pros and cons of using Stored Proc and SQL Queries embedded in Java than it would be a great help..
If there are any articles which proves either of the above is a preferred way, that would also help..
Appreciate the effort in advance !!
Thanks
GurudattWell one benefit of Stored Procs is that you "compile" it on the database whereas you might build your query on the fly in java... test coverage is important in order not to have such things as a typo in a column name....
Still, if you change a table, you have to go through all the procedures in SQL and likely to do so in some of your business object... and trust me, that can be hell!
It all depends on the use of the app...
From my experience, Stored procedure are much faster than built-on-the-fly SQL (and quite faster than prepared statements depending on the JDBC driver, the re-use of connections etc...)....
IMHO, you'd probably be wise to start of with prepared statements, and when the schema seems stable enough (ie unlikely to change), look for the slower queries and convert them to stroed procedures.
If you don't have to support several databases and are tight on performance, you can even include some logic in your stored procedure (e.g. update several tables, based on various selects...etc...). The language is usually quite powerful, and that can save you the run-time of selecting, converting to object , process and update (i.e. several roud-trip between DB and app)...
Tshcuss!
Chris -
Calling Stored Procedures from JAVA Application
Hi all,
i am using JDeveloper 3.2.2 for creating a DB Application that
uses Oracle8i as DB Server.
One approach of the application is to only use PL/SQL Stored
Procedures to write Data back to the DB.
Some of the stored procedures expect more than 20 parameters.
I want to know if there is a better way to call such a stored
procedure from Java than using a CallableStatement and setting
its 20 parameters.
Another reason why the way above isnt possible for me is that
i need a dynamic way to set the parameters of the stored
procedure.
A solution for that dynamic way i could think of is to get
the information of the stored procedure by using some functions
of DatabaseMetaData and than use this information to map the
parameters with their respective variables in the java
application.
The best argument against this way is that it would be time and
performance consuming.
So could anybody tell me a solution to call PL/SQL stored
procedures from java which is better than doing something like:
String calString = "{Call myStoredProc(";
while(counter < 22) {
params += "?";
if(counter<21) params += ",";
counter++;
calString += params + ")}";
try {
CallableStatement cs = session.prepareCall(calString);
} catch(SQLException ex) { ... }
cs.setString(1, var1);
cs.setString(1, var2);
And that for every Stored Procedure i want to call ?!?
Any help or direction-leading would be really appreciated.
Tank you much.
MfG,
Oliver BankelHi Oliver,
If you your Stored Procedures were in Java and seamlessly
integrated with your Java application would that make your life
easier?
I don't know if this is a practical or acceptable solution in
your environment but it would certainly solve all of your issues
and provide your with a couple of nice advantages. Scalability
and platform independence are just a couple I could think of.
There is a tool called in2j (see http://www.in2j.com) which will
automatically migrate your PL/SQL Stored Procedures into Java.
You can download a copy of the tool and migrate your PL/SQL to
Java with no upfront costs. If you're happy with the generated
Java and want to deploy it, the migration fee falls due - simple.
Hope this helps.
Elton -
SQL Queries dont recognize Package member variables.
Hi,
I have a package defined like this:
CREATE OR REPLACE PACKAGE PROD.PKG_BSYS_COMMON
AS
MAX_RETURN_ROWS NUMBER(6) :=1000;
END PKG_BSYS_COMMON;
The problem is that I cannot use MAX_RETURN_ROWS in my SQL queries:
SELECT
FROM
CLIENT
WHERE
ROWNUM < PROD.PKG_BSYS_COMMON.MAX_RETURN_ROWS
Is there any way to use that package member variable in my queries?
This is a simplified explanation of our problem and it is very important for our business to avoid hardcoding constants in queries and define all of them in a central location. Is there a better way doing this?
Any help would be appreciated,
AlanCREATE OR REPLACE PACKAGE PKG_BSYS_COMMON
AS
function max_return_rows return number ;
END PKG_BSYS_COMMON;
CREATE OR REPLACE PACKAGE body PKG_BSYS_COMMON as
function max_return_rows return number is
begin
return(1000);
end;
end PKG_BSYS_COMMON;
select pkg_bsys_common.max_return_rows from dual;
MAX_RETURN_ROWS
1000
Maybe you are looking for
-
How can I attach a whole album to an email? Thanks!
Can I do that? If so, how?
-
Ipod Nano 6th Gen Podcast problem
Hi I have a problem viewing podcasts on my iPod when it is plugged into my (Windows) PC. I have uninstalled and re installed iTunes and I have reset my iPod, but everytime I try to view the list of podcasts (only to add new ones that I have subscribe
-
Why does a Button auto-size itself to completely fill a cell in a Grid if I write the code for it in the .xaml-file but fit to the Button.Content if I drag-and-drop the Button into the Grid from the Controls toolbox? Somehow, the software remembers w
-
Why STO is blocking in GTS ?
I have several STO which is blocking repeatedly in GTS even though STO is taking place within the same countries with different legal entities. It's very time consuming during month end to release manually. Can you please help me on this what could b
-
Basically I want to install a custom reportgen_txt.seq file to the TestStand Dir\Components\Models\TestStandModels upon installation of the program but when I remove the program from my computer I want to keep the custom reportgen_txt.seq file...Righ