Skip to main content

Help in looping and file naming needed.

1 reply [Last post]
gabi684
Offline
Joined: 2009-07-16
Points: 0

Hi guys.
I have this code that is meant to read images from an oracle database.
I want to make it loop e.g. if am reading all the images fro a specific sol_id (i.e. branch) and to also name the picture using the account number (foracid) of the account.

here is the code:

package images;

import java.io.*;
import java.sql.*;

/**
*
* @author user
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try {
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.15:1521:ebfin", "timothy", "timothy");
Statement st = conn.createStatement();
//amt = amt.substring(0, amt.indexOf("."));
String isql = "select gam.foracid,gam.acct_name,imt.acid,imt.cust_id,text_line_1,sign_area from imt,gam where imt.sol_id=gam.sol_id and imt.acid=gam.acid and imt.cust_id=gam.cust_id and foracid='0280190348801'";
ResultSet rs = st.executeQuery(isql);
//ResultSet rs = st.executeQuery("select * from CUSTOM.ISO_MSG");
while (rs.next()) {
//Obtject po = rs.getObject("sign_area");
byte[] po = rs.getBytes("sign_area");
//rs.getBlob("sign_area");
if (po != null) {
FileOutputStream fos = new FileOutputStream(new File("pic1.jpg"));

fos.write(po);
fos.close();

}

}
} catch (Exception expp) {
expp.printStackTrace();
}
}
}

all the help is highly appreciated.
Thanks...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jaywayjohan
Offline
Joined: 2008-06-18
Points: 0

I guess that this is the wrong forum for your question. Try a Java SE forum instead and you will surely have more answers.

Regards
Johan