DICOM objects to MS SQL
Hello everyone. I need to create two interfaces:
1. First one for Oracle with DICOM objects,
2. Second one for MS SQL database.
I want to synchronize Oracle database (some part of tables) with MS SQL. The question is how can I do this (I need synchronize pictures which I'm storing in Oracle (Dicom standard) for MS Sql and open it from second interface)?
E.g. I have 10 databases with the same data (oracle databases with Dicom pictures) and I want to synchronize with one MS Sql database. How can I check which tables from oracle databases is containing the same data (e.g. when we have medical databases and the same person can be in 3 out 10 hospitals/databases). I have seen some suggestions in Internet about XML but I don't know how to do this. I'm sorry for my english. I hope you understand me :) I'll be appreciate for your help.
Q1: I need to create two interfaces: First one for Oracle with DICOM objects
A1: No you don't ... you need to read the docs. Demos here:
http://www.morganslibrary.org/reference/plsql/dicom.html
Q2: I need to create two interfaces: Second one for MS SQL database.
A2: No you don't ... you need to read the docs.
http://tahiti.oracle.com
Finally you wrote: " I have 10 databases with the same data (oracle databases with Dicom pictures) and I want to synchronize with one MS Sql database."
Why? Why would anyone have 10 databases with the exact same information and equally bad want it in two different products? I don't know what country you are in but in the US, Canada, and most of Europe what you are indicating you have and are trying to do would not make it past a government review. You are talking, after all, about personal medical diagnostic information with patient names, hospital names, physician names, etc.
So my advice is that you push yourself away from the keyboard, write a business case justifying what you have (including version numbers and operating systems which you seem to think unimportant) then write a business (not technical) justification for your plans.
What you want to do is easy. What I think you are trying to do like watching a horror movie in a theatre. The ending is going to be really messy with bodies everywhere.
Similar Messages
-
Store file streams into dicom object in oracle 11g (BLOB construct)
The datastream is transfered from network and stored into oracle DB as a blob , then I use the Dicom construct to build the dicom object . The problem is , before I have the blob in the DB , I have to create an empty Blob object ,I use this this empty blob and do the datastream store .
Does somebody have the idea ,how to directly store the datastream into the DB BLOB ,or can I put this BLOB as the variable in JAVA .
my program like this :
stmt.executeUpdate("insert into blob_tbl(id,my_blob) values('" + in + "',empty_blob())");
ResultSet rs = stmt.executeQuery("select my_blob from blob_tbl where id='" + in + "' for update" );
if(rs.next())
Blob blob = rs.getBlob(1);
OutputStream out = ((oracle.sql.BLOB)blob).getBinaryOutputStream();
byte[] b = new byte[((oracle.sql.BLOB)blob).getBufferSize()];
InputStream fin = inStream;
int len = 0;
while( (len = fin.read(b)) != -1)
out.write(b,0,len);
fin.close();
out.close();
conn.commit();The datastream is transfered from network and stored into oracle DB as a blob , then I use the Dicom construct to build the dicom object . The problem is , before I have the blob in the DB , I have to create an empty Blob object ,I use this this empty blob and do the datastream store .
Does somebody have the idea ,how to directly store the datastream into the DB BLOB ,or can I put this BLOB as the variable in JAVA .
my program like this :
stmt.executeUpdate("insert into blob_tbl(id,my_blob) values('" + in + "',empty_blob())");
ResultSet rs = stmt.executeQuery("select my_blob from blob_tbl where id='" + in + "' for update" );
if(rs.next())
Blob blob = rs.getBlob(1);
OutputStream out = ((oracle.sql.BLOB)blob).getBinaryOutputStream();
byte[] b = new byte[((oracle.sql.BLOB)blob).getBufferSize()];
InputStream fin = inStream;
int len = 0;
while( (len = fin.read(b)) != -1)
out.write(b,0,len);
fin.close();
out.close();
conn.commit(); -
How to reference multiple instances of the same Java object from PL/SQL?
Dear all,
I'm experimenting with calling Java from PL/SQL.
My simple attempts work, which is calling public static [java] methods through PL/SQL wrappers from SQL (and PL/SQL). (See my example code below).
However it is the limitation of the public static methods that puzzels me.
I would like to do the following:
- from PL/SQL (in essence it needs to become a forms app) create one or more objects in the java realm
- from PL/SQL alter properties of a java object
- from PL/SQL call methods on a java object
However I fail to see how I can create multiple instances of an object and reference one particular object in the java realm through public static methods.
My current solution is the singleton pattern: of said java object I have only 1 copy, so I do not need to know a reference to it.
I can just assume that there will only ever be 1 of said object.
But I should be able to make more then 1 instance of an object.
To make it more specific:
- suppose I have the object car in the java realm
- from PL/SQL I want to create a car in the java realm
- from PL/SQL I need to give it license plates
- I need to start the engine of a scpecific car
However if I want more then 1 car then I need to be able to refrence them. How is this done?
Somehow I need to be able to execute the following in PL/SQL:
DECLARE
vMyCar_Porsche CAR;
vMyCar_Fiat CAR;
BEGIN
vMyCar_Porsche = new CAR();
vMyCar_Fiat = new CAR();
vMyCar_Porsche.setLicensePlates('FAST');
vMyCar_Porsche.startEngine();
vMyCar_Fiat.killEngine();
END;
Thanks in advance.
Best Regards,
Ruben
My current example code is the following:
JAVA:
===
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED CODAROUL."RMG/BO/RMG_OBJECT" as package RMG.BO;
public class RMG_OBJECT {
private static RMG_OBJECT instance = new RMGOBJECT();
private String rmgObjectNaam;
private RMG_OBJECT(){
this.rmgObjectNaam = "NonDetermined";
public static String GET_RMGOBJECT_NAAM () {
String toestand = null;
if (_instance == null) {toestand = "DOES NOT EXIST";} else { toestand = "EXISTS";};
System.out.println("instance : " + toestand);
System.out.println("object name is : " + _instance.rmgObjectNaam);
return _instance.rmgObjectNaam;
public static Integer SET_RMGOBJECT_NAAM (String IN)
try
_instance.rmgObjectNaam = IN;
return 1;
catch (Exception e)//catch
System.out.println("Other Exception: " + e.toString());
e.printStackTrace();
return 5;
} //catch
PL/SQL Wrapper:
==========
CREATE OR REPLACE FUNCTION CODAROUL.SET_RMGOBJECT_NAAM(NAAM IN VARCHAR2) return NUMBER AS
LANGUAGE JAVA NAME 'RMG.BO.RMG_OBJECT.SET_RMGOBJECT_NAAM (java.lang.String) return java.lang.Integer';
Calling from SQL:
==========
CALL dbms_java.set_output(2000);
select CODAROUL.GET_RMGOBJECT_NAAM() from dual;
Edited by: RubenS_BE on Apr 6, 2012 5:35 AM
Edited by: 925945 on Apr 6, 2012 5:41 AMYou can do this by manually creating a new iterator binding in your binding tab.
So instead of dragging the VO directly to the page, go to the binding tab, add a new executable iterator binding, and point to that one from your ELs in the page itself. -
Can we pass objects to pl/sql block
hi,
can we pass objects to pl/sql block.i think we can.how to pass it.help me in getting the examples of "passing objects to pl/sql block"What exactly do you mean ? You can pass objects like any other parameters
into and out from procedures/functions:
SQL> create or replace procedure get_object(myobj in out nocopy my_obj)
2 is
3 begin
4 dbms_output.put_line('ID : ' || myobj.empno);
5 dbms_output.put_line('Salary : ' || myobj.sal);
6 dbms_output.put_line('Department : ' || myobj.deptno);
7 myobj.sal := myobj.sal*2;
8 end;
9 /
Procedure created.
SQL> declare
2 mo my_obj := my_obj(1,1000,10);
3 begin
4 get_object(mo);
5 dbms_output.put_line('New salary : ' || mo.sal);
6 end;
7 /
ID : 1
Salary : 1000
Department : 10
New salary : 2000
PL/SQL procedure successfully completed.Rgds. -
Connect webdynpro callable object with ms sql server 2000
Hi all
how connect webdynpro callable object with ms sql server 2000?
How can I register on the portal as an additional connection?
thank you very much!Thanks for your answers, Now I have the following problem, to develop this code:
try {
InitialContext iC = new InitialContext();
DataSource dataSource = (DataSource)iC.lookup("jdbc/ConnectionAlias");
Connection con = dataSource.getConnection();
java.sql.Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from ejemplo");
while (rs.next()){
com.sap.test.sql.testsql.wdp.IPrivateTestIViewView.IDatosElement
DatosElement =
wdContext.nodeDatos()
.createDatosElement();
DatosElement.setId(rs.getString("id"));
DatosElement.setNom(rs.getString("nom"));
DatosElement.setNum(rs.getInt("num"));
}catch (SQLException e) {
wdContext.currentContextElement().setB(e.getMessage());
}catch (Exception e){
wdContext.currentContextElement().setB(e.getMessage());
and shows me the following exception
ResourceException in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
the data that you place in the visual administrator were:
Drivers: com.sap.aii.af.jmsproviderlib (msutil.jar , mssqlserver.jar , msbase.jar)
DataSources: sap.com/JDBCConnector_MyDatasource.xml
Name: MyDatasource
Alias: ConnectionAlias
DriverName: com.sap.aii.af.jmsproviderlib
JDBC Version: 1.x
Driver Class: com.microsoft.jdbc.sqlserver.SQLServerDriver
Database URL: jdbc:microsoft:sqlserver://181.42.101.219:1433;DatabaseName=test
User: sa
Password: abcd1234
did not know the cause of the problem
thanks! -
Managing Entity Object and PL/SQL transactions
Hi,
I have requirement to use entity objects and PL/SQL API in the same transaction.
First the data is created in the entity object and then API is called to do some validations on the data created through entity object.
I am not able to fetch the rows created by the entity object in the PL/SQL API until I issue a commit before calling the API.
Can anyone suggest me how to get the data in PL/SQL API which was created by the entity object without commit. As I want to have a commit only after API returns true.
Thanks in advanceOverride the beforeCommit method of the main entity object of your page.
The commit will only take place if the PLSQL does not throw any errors.
See example below:
public void beforeCommit(oracle.jbo.server.TransactionEvent e) {
methodToCheckUsingPLSQL();
super.beforeCommit(e);
private void methodToCheckUsingPLSQL() {
try {
String sql =
"BEGIN check_my_entity(p_id => :1" +
", x_return_status => :2" +
", x_return_msg => :3); END;";
OracleCallableStatement stmt =
(OracleCallableStatement)getDBTransaction().createCallableStatement(sql,
DBTransaction.DEFAULT);
// Rebind parameters
stmt.setNUMBER(1, getId());
stmt.registerOutParameter(2, Types.VARCHAR); //x_return_status
stmt.registerOutParameter(3, Types.VARCHAR); //x_return_msg
stmt.executeUpdate();
String returnStatus = stmt.getString(2);
String returnMsg = stmt.getString(3);
if (!"SUCCESS".equals(returnStatus)) {
throw new OAException(returnMsg);
} catch (Exception e) {
throw new OAException("Error during methodToCheckUsingPLSQL. " +
e.getMessage());
Regards,
Jeroen Kloosterman -
I got an object which manipulate strings, my object is a Java Class.
I need to import my object from PL/SQL?
If is possible, I wanna know how can import my object.
I appreciate some help.
Best Regardshow about exposing your Java Class as a stored procedure? then you can invoke it from PL/SQL through it's Call Spec
I got an object which manipulate strings, my object is a Java Class.
I need to import my object from PL/SQL?
If is possible, I wanna know how can import my object.
I appreciate some help.
Best Regards -
Using REF with object table in SQL Developer
When i create object tables and fill them with data, then in SQL Developer de REF value isn't displayed.
I did the following:
CREATE TYPE adres_type AS OBJECT
(straat VARCHAR2(20)
,nummer VARCHAR2(10)
,postcode VARCHAR2(6)
,plaats VARCHAR2(50));
CREATE TABLE adressen of adres_type;
CREATE TYPE locatie_type AS OBJECT
(nr NUMBER
,naam VARCHAR2(20)
,adres REF adres_type);
CREATE TABLE locaties OF locatie_type;
CREATE TABLE locaties OF locatie_type
(SCOPE FOR (adres) IS adressen);
insert into adressen values (adres_type('Arnhemsestraatweg', '33','6881ND','Velp'));
insert into locaties values (1,'Directie', (select ref (a) from adressen a where a.plaats = 'Velp'))
Then in SQL Developer de REF(A) column is empty, while in SQL*Plus it displays the REF value:
In SQL Developer: SELECT a.*, REF(a) FROM adressen a;
STRAAT NUMMER POSTCODE PLAATS REF(A)
Arnhemsestraatweg 33 6881ND Velp
In SQLPLUS: SELECT a.*, REF(a) FROM adressen a;
STRAAT NUMMER POSTCODE PLAATS REF(A)
Arnhemsestraatweg 33 6881ND Velp 0000280209C70341FBB96B4F77813B27B50E53BB4332382E22ADD64AD9B755F651D416B6DA010134
Is this a bug or is there another reason why the ID doesnt display in SQL Developer.
(this didnt work in all the previous SQL Developer releases and still not in de 2.1 E.A. version)Hi <not sure of your first name>,
I have replicated the issues and logged a bug against this
Bug 9102579 - FORUM: REF FUNCTION NOT RETURNING CORRECT RESULT
Regards,
Dermot O'Neill
SQL Developer Team -
How to change Font Size of Object Explorer in "SQL Server Management Studio"
Dear Team,
"SQL Server Management Studio" is a fantastic IDE for the database.
There are so many customization options available but one thing many users missing is that " How to change Font Size of Object Explorer?"
Can you please accumulate this feature in IDE ASAP?
Many Thanks,
BhaveshIts there
Go to Tools -> Options
Then under Environment you've fonts and colors tab where you can specify a higher font size.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
How to Populate the JTable Object programatically with SQL Results
I'm wondering if someone could help me on how to populate the JTable Object with SQL Results wherein the Row of tjhe JTable object is automatically adjusted depending on how many records you have queried.
Thanks in advance and God bless! (",)
* frmMain.java
* Created on October 4, 2006, 6:15 AM
package tds;
import java.io.*;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.imageio.*;
import javax.swing.JFrame;
import java.sql.*;
import javax.swing.table.DefaultTableModel;
* @author Dexter.Carlit
public class frmMain extends javax.swing.JFrame {
private Connection connection = null;
private DefaultTableModel model;
/** Creates new form frmMain */
public frmMain() {
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jSplitPane = new javax.swing.JSplitPane();
jScrollPane1 = new javax.swing.JScrollPane();
jPanel3 = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
jTree1 = new javax.swing.JTree();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jTextField4 = new javax.swing.JTextField();
jPanel5 = new javax.swing.JPanel();
jScrollPane3 = new javax.swing.JScrollPane();
jGrid = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jProgressBar1 = new javax.swing.JProgressBar();
jPanel2 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
getAccessibleContext().setAccessibleName("frmMain");
jSplitPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jSplitPane.setDividerLocation(200);
jSplitPane.setDividerSize(10);
jScrollPane2.setViewportView(jTree1);
org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel3Layout.createSequentialGroup()
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 916, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
jScrollPane1.setViewportView(jPanel3);
jSplitPane.setLeftComponent(jScrollPane1);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jLabel1.setText("First Name:");
jLabel2.setText("Last Name:");
jLabel3.setText("Position :");
jLabel4.setText("Department:");
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Search Results"));
jGrid.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
new String [] {
"LName", "FName", "Position", "Department", "Office No", "Local No", "Office Mobile No", "Home No", "MobileNo", "Email Address"
jGrid.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
jGrid.setColumnSelectionAllowed(true);
jGrid.setName("");
jGrid.setTableHeader(jGrid.getTableHeader());
jScrollPane3.setViewportView(jGrid);
jScrollPane3.getAccessibleContext().setAccessibleName("rset");
org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
jButton1.setText("Find");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
jButton2.setText("Clear");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4Layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4Layout.createSequentialGroup()
.add(jLabel2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
.add(1, 1, 1))
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4Layout.createSequentialGroup()
.add(jLabel3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE))
.add(jPanel4Layout.createSequentialGroup()
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
jPanel4Layout.linkSize(new java.awt.Component[] {jButton1, jButton2}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jTextField1))
.add(18, 18, 18)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(jTextField2))
.add(16, 16, 16)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(jTextField3)
.add(jLabel4)
.add(jTextField4))
.add(14, 14, 14)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, jProgressBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE))
.addContainerGap())
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
jTabbedPane1.addTab("Search", jPanel1);
org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 458, Short.MAX_VALUE)
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 401, Short.MAX_VALUE)
jTabbedPane1.addTab("Directory", jPanel2);
jSplitPane.setRightComponent(jTabbedPane1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jSplitPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jSplitPane)
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
jGrid.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null}
new String [] {
"LName", "FName", "Position", "Department", "Office No", "Local No", "Office Mobile No", "Home No", "MobileNo", "Email Address"
jGrid.updateUI();
}//GEN-LAST:event_jButton2MouseClicked
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
try {
//Load and register SQL Server driver
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
//Establish a connection
Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://X.X.X.X:1433","MyAccount","MyPassword");
//Create a Statement object
Statement sql_stmt = connection.createStatement();
//Create a ResultSet object, execute the query and return a
// resultset
ResultSet rset = sql_stmt.executeQuery("SELECT * FROM EpxDirectory..Directory Order By LName");
// Populates a JTABLE Object
int i=0;
while (rset.next()){
String LName = rset.getString(1);
String FName = rset.getString(2);
String Position = rset.getString(3);
String Dept_Code = rset.getString(4);
String OffPhoneNo = rset.getString(5);
String LocalNo = rset.getString(6);
String OffMobileNo = rset.getString(7);
String HomePhoneNo = rset.getString(8);
String MobileNo = rset.getString(9);
String Email = rset.getString(10);
jGrid.updateUI();
jGrid.setValueAt(rset.getString(1).trim(),i,0);
jGrid.setValueAt(rset.getString(2).trim(),i,1);
jGrid.setValueAt(rset.getString(3).trim(),i,2);
jGrid.setValueAt(rset.getString(4).trim(),i,3);
jGrid.setValueAt(rset.getString(5).trim(),i,4);
jGrid.setValueAt(rset.getString(6).trim(),i,5);
jGrid.setValueAt(rset.getString(7).trim(),i,6);
jGrid.setValueAt(rset.getString(8).trim(),i,7);
jGrid.setValueAt(rset.getString(9).trim(),i,8);
jGrid.setValueAt(rset.getString(10).trim(),i,9);
i++;
//Close the ResultSet and Statement
rset.close();
sql_stmt.close();
//Close the database connection
connection.close();
System.out.println(Integer.toString(i) + " rows found");
} catch(Exception e) {
System.out.println("Failed to connect; Please view Stack Trace");
e.printStackTrace();
}//GEN-LAST:event_jButton1MouseClicked
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
}//GEN-LAST:event_formWindowOpened
public static void run(){
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
frmMain frmMain = new frmMain();
frmMain.setLocationRelativeTo(null); // Center the JFrame on the
frmMain.setVisible(true);
private void exitApplication() {
// try {
// //gui.putStatus("Closing the connection....please wait.....");
// if(connection != null) {
// // connection.close(); //Closing the connection object.
// } catch(SQLException ex) { //Trap SQLException
// //gui.putStatus(ex.toString());
System.exit(0); //Exit the aplication
* @param args the command line arguments
public static void main(String args[]) {
run();
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JTable jGrid;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JSplitPane jSplitPane;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTree jTree1;
// End of variables declaration//GEN-END:variables
}Use code tags.
Don't mix GUI and JDBC together. Split them out into separate classes.
You have a good start, but you will need to loop through your resultset and also pull the ResultSet metaData for you column headings -
Trying to publish a java object to PL/SQL
Im really new to java and I've been trying to figure this out all day. Can someone PLEASE help me? Im trying to publish a java class I found off the internet to PL/SQL. I Can't seem to get the wrapper right... what am I doing wrong? The class is posted below and all the words bolded is what i've tried so far.. everything seems right for me, as I've done this the same way with a few other java objects..
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "unzip" AS
import java.io.*;
import java.util.*;
import java.util.zip.*;
class unzip
public static void Unzip_File(String args[])
if(args.length < 1)
System.out.println("Syntax : unzip zip-file destination-dir[optional]");
return;
try
ZipFile zf = new ZipFile(args[0]);
Enumeration zipEnum = zf.entries();
String dir = new String(".");
if( args.length == 2 )
dir = args[1].replace('\\', '/');
if(dir.charAt(dir.length()-1) != '/')
dir += "/";
while( zipEnum.hasMoreElements() )
ZipEntry item = (ZipEntry) zipEnum.nextElement();
if( item.isDirectory() ) //Directory
File newdir = new File( dir + item.getName() );
System.out.print("Creating directory "+newdir+"..");
newdir.mkdir();
System.out.println("Done!");
else //File
String newfile = dir + item.getName();
System.out.print("Writing "+newfile+"..");
InputStream is = zf.getInputStream(item);
FileOutputStream fos = new FileOutputStream(newfile);
int ch;
while( (ch = is.read()) != -1 )
fos.write(ch);
is.close();
fos.close();
System.out.println("Done!");
zf.close();
catch(Exception e)
System.err.println(e);
SQL> CREATE OR REPLACE PROCEDURE UNZIP_FILE (
2 P_Z_FILE VARCHAR2,
3 P_Z_FILE_NAME VARCHAR2) AS LANGUAGE JAVA
4 NAME 'unzip.Unzip_File()';
5 /
Procedure created.
SQL> exec unzip_file('D:\Empower\Dev\ACH\ACH_DNLD\RESPONSE.zip', 'D:\Empower\Dev\ACH\ACH_DNLD\ACH_PR
OCESS');
BEGIN unzip_file('D:\Empower\Dev\ACH\ACH_DNLD\RESPONSE.zip', 'D:\Empower\Dev\ACH\ACH_DNLD\ACH_PROCES
ERROR at line 1:
ORA-29531: no method Unzip_File in class unzip
ORA-06512: at "LOANADMIN.UNZIP_FILE", line 0
ORA-06512: at line 1
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PROCEDURE UNZIP_FILE (
2 P_Z_FILE VARCHAR2,
3 P_Z_FILE_NAME VARCHAR2) AS LANGUAGE JAVA
4* NAME 'unzip.Unzip_File(java.lang.String,java.lang.String)';
SQL> /
Procedure created.
SQL> exec unzip_file('D:\Empower\Dev\ACH\ACH_DNLD\RESPONSE.zip', 'D:\Empower\Dev\ACH\ACH_DNLD\ACH_PR
OCESS');
BEGIN unzip_file('D:\Empower\Dev\ACH\ACH_DNLD\RESPONSE.zip', 'D:\Empower\Dev\ACH\ACH_DNLD\ACH_PROCES
ERROR at line 1:
ORA-29531: no method Unzip_File in class unzip
ORA-06512: at "LOANADMIN.UNZIP_FILE", line 0
ORA-06512: at line 1
any help would be great. Thanks in advance :)There are a substantial number of Java demos, and sample code, under $ORACLE_HOME.
-
Unable to pass object from pl-sql to wps
Hi Team
I am trying to pass an object to a different system via WPS 6.2. I am using WPS 6.2 and Oracle 10g.
I want to pass an array of objects returned from a Pl Sql procedure as an output to WPS. However, am unable the object values are not being currently received by WPS. WPS calls this procedure (PlSql), which returns an array of objects. However, it reads the object values as '???'. We tried to write them in an XML
<FetchGENEVACustomerOutput>
<ResponseHeader>
<Status>0</Status>
<ErrorMessage>Accounts Details found for Customer with CRN=525Test_SP_TAM</ErrorMessage>
</ResponseHeader>
<GenevaCustomerDetails>
<AccountNumber>???</AccountNumber>
<ProfileID>???</ProfileID>
<BillingCurrency>???</BillingCurrency>
<InfoCurrency>???</InfoCurrency>
<City>???</City>
<State>???</State>
<BillTerm>???</BillTerm>
<PaymentDueDate>???</PaymentDueDate>
I hope I am posting the question in a comprehensive manner. Never worked with WPS before, it is a different team in our organization. Both of us are trying to solve the issue.
Thanks in anticipationMohan,
Have you tried using UTL_SMTP? It uses UTL_TCP and encapsulates a lot of the stuff you're doing manually, so might be easier. Let me know if you need an example.
Hope this helps,
-Dan
http://www.compuware.com/products/devpartner/db/oracle_debug.htm
Debug PL/SQL and Java in the Oracle Database -
Is there table type object in PL/SQL?
Hi.
What I'm trying to do is, according to the some conditions, aggregate data as an object type( I am not sure that there's a similar thing)
There are 5-6 conditions. then at last join those table type object.
FYI, Here is an example
Company will give bonus to a person who meet these conditions
1. Salary is less than 1000$ - salary table
2. More than 5 persons in his family - staff table
3. gross sale is over 10000$
In PL/SQL Package, I'll get those data as an object type and join those object just like in-line query.
select emp_no
from sal_tbl , staff_tbl, sale_tbl
where sal_tbl = staff_tbl
and sal_tbl = sale_tbl
In my opinion I can get employee list who get bonus. because they meet all conditions.
Reason why bonus condition will be updated continuously. I want to make them easy to maintanence. what if I need to add new conditions. Just add a new procedure that calculate new result and pass as an table type object.
select emp_no
from sal_tbl , staff_tbl, sale_tbl, new_tbl*
where sal_tbl = staff_tbl
and sal_tbl = sale_tbl
and sal_tbl = new_tbl*
Is there any thing just like what I think?
Thanks in advance
Message was edited by: me
allbory
I have read Oracle user guide - Collection, Record, and Cursor. But I can't get anything that I want.
Give me some clues> In PL/SQL Package, I'll get those data as an object type and join those object just like
in-line query.
Not the best of ideas. If I'm getting what you're saying, you want to use the following approach:
SQL> create or replace type TStrings as table of varchar2(4000);
2 /
Type created.
SQL>
SQL>
SQL> create or replace procedure BadIdea( collection TStrings ) is
2 minVal string(4000);
3 maxVal string(4000);
4 begin
5 -- in the procedure we now run SQLs against the collection
6 select
7 MIN( column_value ) into minVal
8 from TABLE( collection );
9
10 select
11 MAX( column_value ) into maxVal
12 from TABLE( collection );
13 end;
14 /
Procedure created.
SQL> show errors
No errors.
SQL>
SQL>
SQL> -- and then we call this procedure to do our "SQL" processing for us
SQL> declare
2 list TStrings;
3 begin
4 select
5 object_name bulk collect into list
6 from user_objects;
7
8 BadIdea( list );
9 end;
10 /
PL/SQL procedure successfully completed.A collection of objects resides in (non-sharable and expensive) PL/SQL memory. Running SQL, requires the PL/SQL engine copying the data to the SQL engine into a structure and format that the SQL engine will understand.
This is slow. This is expensive. This does not scale.
It makes little sense to copy data from the very fast and hot and good and scalable db buffer cache into an expensive memory structure in the PGA and then run SQLs against that.
> Reason why bonus condition will be updated continuously. I want to make them easy
to maintanence. what if I need to add new conditions. Just add a new procedure that
calculate new result and pass as an table type object.
The way I read your SQL, your new_tbl* requires dynamic SQL. Which means you also need to dynamically cater for the correct column names to join on, to filter on, and to select from.
Also not the best of ideas. Dynamic SQL like that requires a lot of code to deal correctly with bind variables. Lot of exception handling as there can easily be run-time errors as the code itself that is executed in turn creates new dynamic code to execute.
If this is to be truly dynamic, then one approach would be that each rule needs to be executable as a SQL or PL/SQL block. Each rule needs to have an input like an employee number. Each rule needs to returns a boolean like value, saying whether the rule has passed or failed.
Only when all the rules have been passed, can the bonus be allocated.
This will deal fine with the "dynamic rule" requirement. Performance wise and scalability wise.. it may not be the best of ideas. 10 dynamic and very slow and expensive rules, could very well be rewritten as a one very fast and very cheap static SQL statement.
Anyway, the dynamic rule approach can look something like the following:
SQL> create or replace type TBonusRule is object
2 (
3 result# char(1),
4 member function Passed return boolean
5 )
6 not final;
7 /
Type created.
SQL> show errors
No errors.
SQL>
SQL>
SQL> create or replace type body TBonusRule is
2 member function Passed return boolean is
3 begin
4 return( UPPER(self.result#) = 'Y' );
5 end;
6 end;
7 /
Type body created.
SQL> show errors
No errors.
SQL>
SQL>
SQL> create or replace type TBonusSQLRule under TBonusRule
2 (
3 constructor function TBonusSQLRule( empNo number, sqlStatement varchar2 ) return self as result
4 ) final;
5 /
Type created.
SQL> show errors
No errors.
SQL>
SQL>
SQL> create or replace type body TBonusSQLRule is
2 constructor function TBonusSQLRule( empNo number, sqlStatement varchar2 ) return self as result is
3 begin
4 execute immediate sqlStatement
5 into self.result#
6 using IN empNo;
7
8 return;
9 end;
10
11 end;
12 /
Type body created.
SQL> show errors
No errors.
SQL>
SQL> set serveroutput on
SQL> declare
2 rule1 TBonusSQLRule;
3 rule2 TBonusSQLRule;
4 empNo number;
5 begin
6 empNo := 7369; -- we process employee 7369
7
8 -- we apply bonus rule 1 that check if the employee is a clerk (of course,
9 -- we could be reading these rules from a rules table - this example simply
10 -- creates them dynamically)
11 rule1 := new TBonusSQLRule( empNo, 'select ''Y'' from emp where empno = :0 and job=''CLERK''' );
12
13 if rule1.Passed then
14 DBMS_OUTPUT.put_line( 'Rule 1. PASSED' );
15 else
16 DBMS_OUTPUT.put_line( 'Rule 1. FAILED' );
17 end if;
18
19 -- rule 2 can for example check if the employee has been working for at least 5 years for the
20 -- company
21 rule2 := new TBonusSQLRule( empNo, 'select ''Y'' from emp where empno = :0 and (SYSDATE-hiredate)>5*365' );
22
23 if rule2.Passed then
24 DBMS_OUTPUT.put_line( 'Rule 2. PASSED' );
25 else
26 DBMS_OUTPUT.put_line( 'Rule 2. FAILED' );
27 end if;
28
29 end;
30 /
Rule 1. PASSED
Rule 2. PASSED
PL/SQL procedure successfully completed.
SQL>
PL/SQL rules can in a similar fashion be subclassed from the base/asbtract class. And rules can be persisted in a table too.
But even though I did this example to illustrate just how flexible Oracle can be, I would personally think hard before using the above approach myself.
Why?
Because rules 1 and 2 resulted in two SQLs being fired. A single SQL could have done the job.
2 SQLs were used for a single employee. I can use a single SQL to find ALL employees that matches the rule criteria.
So... not very scalable and not very fast. -
Object Library/PL-Sql Library Use?
1. I would like to know the benefits of the new concepts like
Object library and Object Group etc. All I gather is that they
can be subclassed, the advantage of this being, I need to change
only at one place, and it replicates in rest of the programs.
2. Is there going to be any benefit of having the
procedures/objects in PLSQL Library/Object library rather than
in Object Group within the form .
nullThe query in your code actually generates a string that is 3887 bytes long:
SQL> ed
Wrote file afiedt.buf
1 SELECT length(LISTAGG (LEVEL, ' ') WITHIN GROUP (ORDER BY LEVEL))
2 FROM DUAL
3* CONNECT BY LEVEL < 1000
SQL> /
LENGTH(LISTAGG(LEVEL,'')WITHINGROUP(ORDERBYLEVEL))
3887
The reason you are getting 7774 is because your database is obviously set up for a multi byte character set, so the length is determining 2 bytes for each stored character (2*3887 = 7774). You're not actually storing more than 4000 bytes. Try changing your query to add another 25 numbers to the string and it'll break... as you're exceeding the 4000 byte limit...
SQL> ed
Wrote file afiedt.buf
1 SELECT length(LISTAGG (LEVEL, ' ') WITHIN GROUP (ORDER BY LEVEL))
2 FROM DUAL
3* CONNECT BY LEVEL < 1025
SQL> /
FROM DUAL
ERROR at line 2:
ORA-01489: result of string concatenation is too long -
SCSM object history from sql cmdb
HI.
In this post explain how to accessing object history programmatically using the SDK http://blogs.technet.com/b/servicemanager/archive/2011/09/16/accessing-object-history-programmatically-using-the-sdk.aspx
I try to do this from sql query. And get trouble. Can you help me?You cannot write a single query to get the history of all the CIs. You have to decide which CIs you want to track as each CI has its own table and columns. They all derive from System.ConfigItem but it is a abstract class so there is no table for it.
For example: If you want to write a report to capture the history of all Computer CIs, the tables you will be interested in will be MT_Computer, MT_Computer_Log. Then you have to compare Pre and Post columns.
To capture what kind of change, you need to query EntityChangeLog table.
Here is the good article that may be able to help you:
http://www.concurrency.com/blog/service-manager-useful-queries-entity-change-log/
Maybe you are looking for
-
I removed Bing from my computer as I did not like it much. Since Google has now become such a useless piece of junk I decided to re-install Bing but each time I try I get the following message. Quiote: Firefox could not install the search plugin from
-
Service entry update in SRM SUS
Dear All, We are in SRM7, using MM-SUS,creting a confirmation for a service PO from SUS It is creating a service entry in MM. After service entry release it created a GR as per the standard procedure. Now when i run RPODDELIVERY update sending out of
-
I need a method of automatically installing patches from a local patch server ... for security reasons, we have no internet connectivity (absolutely no physical connection). Sun Patch Manager 2 seemed the perfect solution ... but have just found it i
-
Can I turn off the InPrivate notice when I start in InPrivate mode?
I have a shortcut that starts IE in InPrivate mode. But what comes up is the InPrivate "warning". I want it to just start in InPrivate mode and go to my homepage. Is there a setting to do that? We are setting up a kiosk for some of our warehouse g
-
System MTU size on Cisco switch
after setting sys mtu to something other than 1500 on a WS-C3750G-24TS-1U it appears that this setting will stay in effect even if the startup config is erased and the switch is reloaded. My question is. Does this mean that if I need to replace the s