Anyone knows about using java to get data from MS Access database.
hi there
anyone knows about using java to get data from MS Access database? thank you
there is a list of jdbc drivers at:
http://industry.java.sun.com/products/jdbc/drivers
they have several ms access drivers listed.
also, you can use a jdbc-odbc bridge which allows you to use jdbc to connect to any odbc data source:
http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/bridge.doc.html
Similar Messages
-
Trying to use FTP to get data from a different server
Hi Friends,
I have to use FTP to get data from a different server and upload it on SAP server. Now my problem is when I m trying to do ftp through command line it brings the file but with no data.
Through ABAP program nothing is happening.
Here's my code--
V_PASSWORD = 'test@123'.
V_PWD_LEN = STRLEN( V_PASSWORD ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = V_PASSWORD
SOURCELEN = V_PWD_LEN
KEY = CS_KEY_500098
IMPORTING
DESTINATION = V_PASSWORD.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
USER = 'test'
PASSWORD = V_PASSWORD
HOST = '176.0.1.6'
RFC_DESTINATION = 'SAPFTPA'
IMPORTING
HANDLE = MI_HANDLE
EXCEPTIONS
NOT_CONNECTED = 1
OTHERS = 2.
CHECK SY-SUBRC = 0.
cmd = 'lcd d:\ftp'. .
PERFORM FTP_COMMAND USING CMD.
CMD = 'asc'.
PERFORM FTP_COMMAND USING CMD.
CONCATENATE 'dir' 'ftpt*' INTO CMD SEPARATED BY SPACE.
PERFORM FTP_COMMAND USING CMD.
cmd = 'ls'.
concatenate 'ls' INTO CMD SEPARATED BY SPACE.
PERFORM FTP_COMMAND USING CMD.
cmd = 'mget trial.txt'.
CONCATENATE 'mget' 'trial.txt' INTO CMD SEPARATED BY SPACE.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = MI_HANDLE
COMMAND = CMD
TABLES
DATA = MTAB_DATA1
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
IF SY-SUBRC = 0.
LOOP AT MTAB_DATA1.
WRITE: / MTAB_DATA1.
ENDLOOP.
ELSE.
CONCATENATE 'Error in FTP Command while executing' CMD INTO ERROR SEPARATED BY SPACE.
WRITE: / ERROR.
ENDIF.Hi
try this.....in one of my reqt, i done this successfully....
FORM FTPCON.
FTP-------------------------------------------------------*
CLEAR DSTLEN.
SET EXTENDED CHECK OFF.
DSTLEN = STRLEN( S_PWD ). -
> (S_PWD (password) is a selection screen field )
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = S_PWD
SOURCELEN = DSTLEN
KEY = KEY
IMPORTING
DESTINATION = S_PWD.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
USER = P_USER -
> Username
PASSWORD = S_PWD -
> password
HOST = P_HOST -
> Host
RFC_DESTINATION = P_DEST -
> Destination
IMPORTING
HANDLE = HDL
EXCEPTIONS
NOT_CONNECTED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
COMMAND = 'set passive on'
TABLES
DATA = RESULT
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = HDL
FNAME = G_FCNAME
CHARACTER_MODE = 'X'
TABLES
TEXT = T_FILE1
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = HDL
FNAME = G_FCNAME1
CHARACTER_MODE = 'X'
TABLES
TEXT = T_FILE2
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
HANDLE = HDL.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
DESTINATION = P_DEST
EXCEPTIONS
DESTINATION_NOT_OPEN = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " FTPCON
Hope it helps..... -
base /open SQL Statement etc) the first time i defined the system everything was fine but when i changed the Database (using M.S.Access) the " open SQL Statement" it would show the tables but not thier columns ,I"m using win98 sec edition / Teststand 1.0.1i need to pass data from an Access database to Teststand by using the built in Data step types(open database /open SQL Statement etc) the first time i defined the system everything was fine but when i changed the Database (using M.S.Access) the " open SQL Statement" it would show the tables but not thier columns ,I"m using win98 sec edition / Teststand 1.0.1
When I tried the same thing on another cmputer the same thing
happend
appreiciate u"r helpbase /open SQL Statement etc) the first time i defined the system everything was fine but when i changed the Database (using M.S.Access) the " open SQL Statement" it would show the tables but not thier columns ,I"m using win98 sec edition / Teststand 1.0.1Hello Kitty -
Certainly it is unusual that you can still see the tables available in your MS Access database but cannot see the columns? I am assuming you are configuring an Open Statement step and are trying to use the ring-control to select columns from your table?
Can you tell me more about the changes you made to your file when you 'changed' it with MS Access? What version of Access are you using? What happens if you try and manually type in an 'Open Statement Dialog's SQL string such as...
"SELECT UUT_RESULT.TEST_SOCKET_INDEX, UUT_RESULT.UUT_STATUS, UUT_RESULT.START_DATE_TIME FROM UUT_RESULT"
Is it able to find the columns even if it can't display them? I am worried that maybe you are using a version of MS Access that is too new for the version of TestSt
and you are running. Has anything else changed aside from the file you are editing?
Regards,
-Elaine R.
National Instruments
http://www.ni.com/ask -
Using streams to capture data from physical standby database.
Does anybody know if it is possible to use streams to capture data from physical standby database instead of PROD database? The standby database is in read only mode. We use Oracle 11gR2.
Thanks in advance.physical are closed : how will it managed the queues and overspill queues when target is not present? Also the data dictionary must reflect the primary but If you run capture, then you introduce rules that are not on primary: How ?
-
Retrieve data from MS Access database.
Hi all,
The following is part of my coding. Once I have clicked the jButton1, the jTextField1 will get the input of user and store into a variable named "bbb". After that the variable will be passed to a function as a parameter to retrieve data from MS Access database using the ResultSet method. Next, the ResultSet will be splited into many part and just the student ic will be displayed.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String bbb = jTextField1.getText(); //get input from user and store into a variable named bbb
ResultSet codes = getCodes(bbb); //Retrieve data from database
Code c = getCode (codes); //split the retireved date to many part
jLabel2.setText(c.ic); //display the student ic only
private static ResultSet getCodes(String bbb)
Connection con = getConnection();
try
Statement s = con.createStatement();
String select = "SELECT [Student-File].* " + "FROM [Student-File] WHERE (([Student-File].[student-code])=bbb); " ;
ResultSet rows;
rows = s.executeQuery(select);
return rows;
catch (SQLException e)
System.out.println(e.getMessage());
return null;
private static Code getCode (ResultSet codes)
try
String name = codes.getString("student-name");
String scode = codes.getString("student-code");
String ic = codes.getString ("student-ic");
String add = codes.getString ("student-address");
String phone = codes.getString ("student-phone");
return new Code (name,scode,ic,add,phone);
catch (SQLException e)
System.out.println(e.getMessage());
return null;
private static class Code
public String name ;
public String scode ;
public String ic ;
public String add;
public String phone;
public Code (String name, String scode, String ic,String add,String phone)
this.name = name;
this.scode = scode;
this.ic = ic;
this.add = add;
this.phone = phone;
}But after I have compiled the coding above, the following error existed.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
at testing3.getCode(testing3.java:137)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
at testing3.jButton1ActionPerformed(testing3.java:71)
at testing3.access$000(testing3.java:17)
at testing3$1.actionPerformed(testing3.java:45)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at testing3.getCode(testing3.java:137)
at testing3.jButton1ActionPerformed(testing3.java:71)
at testing3.access$000(testing3.java:17)
at testing3$1.actionPerformed(testing3.java:45)
My questions here are:
1) Will my idea above work?
2) Is it correct of my query statement that send to MS Access database?
Can anyone help me?
Thanks in advance,
ning.you may try this:
String select = "SELECT * FROM your_table_name WHERE your_column_name = '" + bbb + "'";or another approach using PreparedStatement:
String select = "SELECT * FROM your_table_name WHERE your_column_name = ?";
PreparedStatement ps = con.prepareStatement(select);
ps.setString(1, "bbb");
ResultSet rs = ps.executeQuery();hth. -
Oracle select data from ms access database
please dear sirs,
exactly what i need is when i make select statment from oracle sql, i can select data from ms access database
please help me
thanks in advance
Yasser
Edited by: user4490340 on 27-Oct-2010 01:09You will need to use ODBC. Pl post details of OS and database versions.
http://download.oracle.com/docs/cd/E11882_01/gateways.112/e12070/intro.htm
HTH
Srini -
Data type structure while picking data from MS Access database
Dear All,
I have to start on new interface in which data from MS Access database will be updated in the z-table in SAP. Is there any blog available which gives step by step process for MS Access-XI-RFC interface. Or please guide me on what should be the structure of the Data Type for picking the data from the MS Access database.
Regards,
NJHi Nishu,
Sender side the structure is as follows
db_sen_dt
..... emp_row
.......... f1
.......... f2
Structure is complex then check this blog
/people/alessandro.berta/blog/2005/10/04/save-time-with-generalized-jdbc-datatypes
JDBC to RFC Scenario, but it is synchronous
SYNCHRONOUS SOAP TO JDBC - END TO END WALKTHROUGH
Also check this link
Regards
Ramesh -
How to use RFC to get data from BW?
Hi all, we need to get data from BW using RFC, I am not familiar with BW and RFC, would you please give me some advice? Many thanks in advance!
would you please bring your solution to light here?
thank you
God's blessing
Andreas -
How to get data from MS Access?
How can select data from MS Access datafile, stored on some computer in local network? How to connect Oracle database to MS Access datafile? I tried use ODBC, but unsuccefull. Any idea? Some link to some guide?
mihaelradovan wrote:
How can select data from MS Access datafile, stored on some computer in local network? How to connect Oracle database to MS Access datafile? I tried use ODBC, but unsuccefull. Any idea? Some link to some guide?How were you "unsuccessful"?
You set up an ODBC connection to the MS Access file, then use Oracle Heterogeneous services and configure those to point to the ODBC connection and use that.
Here's an example I already have for an MS Excel file...
1- Go to Control Panel>Administrative Tools>Data Sources (ODBC)>System DSN and create a data source with appropriate driver. Name it EXCL.
2- In %ORACLE_HOME%\Network\Admin\Tnsnames.ora fie add entry:
EXCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.0.24)(PORT = 1521))
(CONNECT_DATA =
(SID = EXCL)
(HS = OK)
Here SID is the name of data source that you have just created.
3- In %ORACLE_HOME%\Network\Admin\Listener.ora file add:
(SID_DESC =
(PROGRAM = hsodbc)
(SID_NAME = <hs_sid>)
(ORACLE_HOME = <oracle home>)
under SID_LIST_LISTENER like:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = d:\ORA9DB)
(PROGRAM = extproc)
(SID_DESC =
(GLOBAL_DBNAME = ORA9DB)
(ORACLE_HOME = d:\ORA9DB)
(SID_NAME = ORA9DB)
(SID_DESC =
(PROGRAM = hsodbc)
(SID_NAME = EXCL)
(ORACLE_HOME = D:\ora9db)
Dont forget to reload the listener
c:\> lsnrctl reload
4- In %ORACLE_HOME%\hs\admin create init<HS_SID>.ora. For our sid EXCL we create file initexcl.ora.
In this file set following two parameters:
HS_FDS_CONNECT_INFO = excl
HS_FDS_TRACE_LEVEL = 0
5- Now connect to Oracle database and create database link with following command:
SQL> CREATE DATABASE LINK excl
2 USING 'excl'
3 /
Database link created.
Now you can perform query against this database like you would for any remote database.
SQL> SELECT table_name FROM all_tables@excl;
TABLE_NAME
DEPT
EMPOr refer to this Article...
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4406709207206 -
Using Java to Log Data from another program
I have a program that I want to log data from while the program is running. The program has a textarea that gets updated with data from the internet. I want to be able to read this textarea and store the data so it can be analyzed later.
I don't know what the program was written in, only that it is running on Windows.
Can Java "watch and read" another program?i think that easyest way would be to listen for network traffic and then parse relevant information from there...
you could make a java app to act as proxy for that programm (maybe) and then log everything that goes through socket, or if you don't want to do that, then you could also use some other software that can listen network and look from there information that intrests you...
of other softwares id recommend somekind of Iris soft that i used 3-4 years ago... realy easy to use nd runs on windows as well... even better would be ngrep, but i don't know if it has any windows versions... -
Does anyone know how to remove non-music data from ipod?
Does anyone know how to get the data that is not songs off of the ipod. I cannot figure it out
With disk use enabled, you just open the iPod in Finder. You should be able to see the folder with the photos in it. If you want to copy them to a place on your computer, just drag them there, or to delete them altogether from the iPod, drag them to the trash.
-
Use Java to collect data from HTML
Hi Guys
I am doing a online stock trading project, the main part is to collect raw data from http://finance.yahoo.com User can retrieve the stock detail by inputting the right stock symbol, such as "AOL". I dont have too much problem in this part because yahoo provde a spreedsheet format to display the result. If you type the URL below, it can bring you a set of stock data separating by comma. So, I can use StringTokenizer(date, ",") to collect each data from yahoo into my system.
========================================================================
http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s=AOL&
"AOL",15.57,"8/12/2003","4:01pm",+0.04,15.47,15.63,15.40,12097200
========================================================================
However beside this function, I also need to search Stock Symbol, because user may only know the company name. Although Yahoo finance also provide this function, with no spreedsheet format provided. So, if I type the URL below, it will only give me a set of result BUT in HTML format.
========================================================================
http://finance.yahoo.com/l?s=AOL&t=S&m=
========================================================================
So, can anyone tell me what is the best way to collect data from a HTML page? Or anyone know any good stock quoting sites which also provide spreedsheet format?
Thank you very much
KelI am doing a online stock trading project, the
the main part is to collect raw data from
http://finance.yahoo.com
Sounds fun.
So, can anyone tell me what is the best way to
to collect data from a HTML page? Or anyone know any
good stock quoting sites which also provide
spreedsheet format?I really don't know any other stock quote sites. But if you want to implement a search function for stock names, I would do it like this
1) Code the HTTP SUBMIT/POST to lookup the possible stock names
2) Use XSL to filter out the HTML path to the table with results, the layout is consistent, so there are no strange exceptions. You can check the DOM structure by using Mozilla's DOM inspector. Just write down the path to the TABLE element and select it, and transform it to CSV for example.
3) Reparse the CSV to fill some boxes
To possibly save some server load use a small fixed size in memory cache to store N requests based on some strategy.
The other part is actual a separate part of what you want to code and should be a separate class in which you can feed the stock name.
If the user types in a bad stock name, you can retrieve a list of possible names using the input as the company name.
Greets.
Maybe there is a SOAP service out there somewhere. -
BPM getting data from multiple JDBC databases
Hi - a 'high level' question...
I have a scenario where the first step in my bpm is a receive step which will be a JDBC send adapter/comm channel to a particular database. The rows returned will have a key field called "ID". For each of these rows, I need to go to a completely different JDBC database to gather more data based on this key "ID".
Not sure how to go about this, but this is my best guess
1) receive step, asynchronous which will be used by the jdbc send adapter
2) create a block, mode ForEach referring to the messages returned in the initial receive step. In this block there will be:
3)THIS IS THE PART I'M CONFUSED ON - do i need a synchronous send step, with the request message being the message from the initial receive and a response message being the message from the JDBC recieve adapter? How does the "ID" get passed in to select the proper record? How is a SQL created to get the proper record from the second database?
4 etc) After that, it would be a straight forward transform and send to the target system...which i'm ok with.
Again, my confusion is how the key field is somehow passed to the second JDBC call.
any assistance or clarification would be greatly appreciated! thanks /daveHI,
<i>For each of these rows, I need to go to a completely different JDBC database to gather more data based on this key "ID"</i>
>>>To gather more data, means you are going to select the data for each key ID. Then this data you need to send to target system right ? If so, you need to have Synchronous Send from BPM.
Your BPM steps will be like this
1) Receive the message from Database(JDBC sender)
2) Block with Foreach
3) Send the data Synchrnously to the other database with the help of Reciever JDBC adapter
4) Receive the Response, and Send this Asynchrnoulsy to the Target System.
DO you need Foreach loop here , i am just thinking ? You can pass multplr Key Values to the JDBC Receiver structure and get the Response at a time.
For more on JDBC Sync-
/people/bhavesh.kantilal/blog/2006/07/03/jdbc-receiver-adapter--synchronous-select-150-step-by-step
Regards,
Moorthy -
Attempting to Save data from an access database file into a local variable for use.
Hello! i'm trying to develop a small text based game in Visual Basic 2013 and I've recently decided i need to use a more sophisticated data storage system then dozens of .txt files and stream-readers. i'm using Microsoft access and i completed my database
last night. it stores the stat and skill values of the player-character and the non-player characters. the problem is i cannot bring the data into visual basic in a usable way. using ado.net i can bring a single record into the system as a detail view and
then read the data in from the labels but i'd far prefer to have it done purely through code. the book i purchased only covers data grid views and detail view and I've spent several hours searching for a solution online.
for clarification. i need to read each value in a record into a variable so i can calculate the stats for the games combat system.So, you want to select from MS Access?
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Ryan\Desktop\Coding\Microsoft Access\Northwind_2012.mdb"
Dim selectCommand As String
Dim connection As New OleDbConnection(connectionString)
selectCommand = "Select * From MyExcelTable ORDER BY ID"
Me.dataAdapter = New OleDbDataAdapter(selectCommand, connection)
With DataGridView1
.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader
End With
Dim commandBuilder As New OleDbCommandBuilder(Me.dataAdapter)
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
Me.dataAdapter.Fill(table)
Me.bindingSource1.DataSource = table
Dim data As New DataSet()
data.Locale = System.Globalization.CultureInfo.InvariantCulture
DataGridView1.DataSource = Me.bindingSource1
Me.DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Aqua
Me.DataGridView1.AutoResizeColumns( _
DataGridViewAutoSizeColumnsMode.AllCells)
End Sub
Then from DataGridView to a text file, right.
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim dt As DataTable = New DataTable
Dim DBAdapter As OleDbDataAdapter = New OleDbDataAdapter
Dim connection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\Excel\\Desktop\\Coding\\Microsoft Access\\Nor"& _
"thwind.mdb;Jet OLEDB:System Database=system.mdw")
Dim query As String = "SELECT * FROM Orders;"
connection.Open
Dim command As OleDbCommand = New OleDbCommand(query, connection)
Dim adapter As OleDbDataAdapter = New OleDbDataAdapter(command)
adapter.Fill(dt)
Dim writer As StreamWriter = New StreamWriter("C:\\Users\\Excel\\Desktop\\FromAccess.txt")
For Each Row As DataRow In dt.Rows
For Each values As Object In Row.ItemArray
writer.Write(values)
Next
Next
writer.Close
End Sub
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
Getting image from Microsoft Access database to display in browser
Hey! anybody please help me
I've been trying with no success to get an image from a microsoft access database
so far this is what i have:
package Servlets;
import java.io.*;
import java.net.*;
import utils.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class serv extends HttpServlet {
java.sql.ResultSet rs=null;
ClsConexion conexion=new ClsConexion("Nedermex");
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
conexion.conectate("1", "1");
rs=conexion.obtenRegSelect("SELECT * FROM Flores WHERE ID=1");
try{
rs.next();
System.out.println("sadfsadf " + rs.getString("ID"));
}catch(Exception e){
e.printStackTrace();
String ubicGIF = request.getParameter("ubicGIF");
if((ubicGIF==null) || ubicGIF.length() == 0 ){
indicarError(response, "Archivo de imagen no establecido");
return;
//String archivo = getServletContext().getRealPath(ubicGIF);
try{
if(rs.next()){
System.out.println("sadfsadf " + rs.getString("ID"));
BufferedInputStream ingreso = new BufferedInputStream(rs.getBinaryStream("Imagen"));
// BufferedInputStream ingreso = new BufferedInputStream(new FileInputStream(getServletContext().getRealPath("1.jpg")));
ByteArrayOutputStream flujoBytes = new ByteArrayOutputStream(512);
int byteImagen;
while ((byteImagen= ingreso.read()) != -1){
flujoBytes.write(byteImagen);
ingreso.close();
String indiPersistencia = request.getParameter("usePersistence");
boolean usePersistence = ((indiPersistencia == null) || (!indiPersistencia.equals("no")));
response.setContentType("image/jpeg");
if(usePersistence){
response.setContentLength(flujoBytes.size());
flujoBytes.writeTo(response.getOutputStream());
}catch(IOException ioe){
indicarError(response, "Error: " + ioe);
}catch(java.sql.SQLException sqle){
indicarError(response, "Error: " + sqle);
public void indicarError(HttpServletResponse response, String mensaje) throws IOException {
response.sendError(response.SC_NOT_FOUND, mensaje);
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Returns a short description of the servlet.
public String getServletInfo() {
return "Short description";
// </editor-fold>
}i have a class Conexion wich controls the connection and resultsets
As you can see, i tested accessing a jpeg file: 1.jpg with FileInputStream, and it works perfectly, but when i try to get an image from Microsoft Access using the resultset the way i did, the browser shows the following message
The image �http://localhost:8084/Nedermex/serv� cannot be displayed, because it contains errors.
My table in the database in Access is configured as following
FieldName::::::::::::::DataType
ID::::::::::::::::::::::::::::::Number
Imagen::::::::::::::::::::OLE Object
Now, when i insert an image in the Imagen field, i select the option "Create from file" and select the jpg file (the one that worked with the FileInputStream) and uncheck the Link option (to save the data in the db
maybe there is something wrong with the sizes or something....
please help me here!!!
thank you!Yes it is an sql question
Consider this as my condition need to fetch records collected in database on 16-4-2012
Table name =TEST_REPORT
i have passed the following query
Select Serial_Number,System_Date,System_Time,Department,Operator_Name,Serial_Number,Test_Case,Pass_Fail from TEST_REPORT where System_Date = 4-16-2012, it displays the entire record from database. i have my vi along with this mail.
Attachments:
Report Viewer.vi 24 KB
Maybe you are looking for
-
No video out on TV using Satellite A50-542
I am not able to get an output from the video out jack on my Satellite A50-542 laptop. I have connected the laptop to my TV via a s video cable and an oudio cable via the headphone jack. Sound is fine but no video. Tried connecting from s video jack
-
N500 HDMI at Windows XP SP3 doesn't work
Hy! I installed XP SP3 on N500 , i installed every driver what i found lenovo site's ( but nvidia driver not ,because it write my machine has got intel video card). When i connect HDMI cable and put into the TV nothing happening only i can watch the
-
Layers in my PDF which are switched to visible are not showing - how do I solve this?
I am creating MXD files in Arc GIS, and then exporting them to Adobe Professional 8. I am merging layers within Adobe Pro, and then switching the initial view so that only 4 out of the ~10 layers are visible when the PDF is first opened. However, on
-
Is it possible to shutdown TestStand LabWindows/CVI operator interface programmatically?
Hi, Like the title says, I'm trying to find a way to shutdown TestStand operator interface automatically after sequence execution is completed. Any suggestion is appreciated, thanks in advance.
-
HT4528 How do you download pics from iPhone to laptop w/o a usb cord?
how do you download pics to laptop?