file 3 « file « Java Database Q&A

Home
Java Database Q&A
1.Blob
2.cassandra
3.column
4.Connection
5.Cursor
6.dao
7.Data Type
8.Database
9.Database Product
10.DataSource
11.Date
12.db2
13.derby
14.Development
15.Driver
16.Exception
17.file
18.hadoop
19.hbase
20.hsqldb
21.ibatis
22.JDBC
23.memcached
24.mongodb
25.MS Access
26.mysql
27.ODBC
28.Operation
29.oracle
30.postgresql
31.Record
32.result
33.Resultset
34.Schema
35.SQL
36.sqlite
37.SQLserver
38.Statement
39.stored procedure
40.sybase
41.Table
42.Transaction
43.Trigger
Java Database Q&A » file » file 3 

1. CSV file to database    coderanch.com

2. Store PDF files in the database    coderanch.com

3. Java Upload file into database field    coderanch.com

I have a Java/JSP web site based on an Oracle 9i database. I'm trying to upload files and insert them directly into a table in my database. I'm currently using the follow code: fs = new FileInputStream(file); Class.forName("oracle.jdbc.driver.OracleDriver"); connection=DriverManager.getConnection("jdbcracle:thin:@---","xxx","xxx"); connection.setAutoCommit(false); pstmt = connection.prepareStatement("INSERT INTO UploadsTable (ID,Uploadfile) VALUES (1,file)" ); pstmt.setInt(1,123); pstmt.setBinaryStream(2,fs,(int)file.length()); pstmt.executeUpdate(); pstmt.close(); fs.close(); The code uploads; however, saves the file ...

4. Java Upload file into database field    coderanch.com

I have a Java/JSP web site based on an Oracle 9i database. I'm trying to upload files and insert them directly into a table in my database. I'm currently using the follow code: fs = new FileInputStream(file); Class.forName("oracle.jdbc.driver.OracleDriver"); connection=DriverManager.getConnection("jdbcracle:thin:@---","xxx","xxx"); connection.setAutoCommit(false); pstmt = connection.prepareStatement("INSERT INTO UploadsTable (ID,Uploadfile) VALUES (1,file)" ); pstmt.setInt(1,123); pstmt.setBinaryStream(2,fs,(int)file.length()); pstmt.executeUpdate(); pstmt.close(); fs.close(); The code uploads; however, saves the file ...

5. Storing a pdf file in database    coderanch.com

6. Storing uploaded files straight into a database    coderanch.com

Hi to all, This has been bugging me for some time now and I finally thought I would come out clean and ask. I am aware that many realational databases can store files such as images directly into them but I don't see this done much. Let me explain, I work for a web development agency here in the UK and ...

7. Jar file for JDBC...    coderanch.com

9. create multiple files in access db    coderanch.com

I need to access MS Access db and loop through the tables. if the total number of the records exceed 10,000, I will create another file. so if I have 100,000 records in the file, I should create 10 files out of it. I have little idea of how to implement it. does anyone have any idea? Thank you very much! ...

10. Blob/Clob or Files    coderanch.com

What are the advantages of Blob/clobs over files, assuming that the files are non-corruptible and safe? Instead of storing data as blobs, why shouldn't i just store them as files on hdd and store the path in db? Please advise. Also, when should one be opted over another? I need to store movie files of the order of max 50mbs. What ...

12. I need to break a .mde file into smaller files    coderanch.com

Well... I googled MDE files to find out what they are. Looks to me like an MDE file is a compiled version of an Access database. One of their purposes is to secure the database from being changed by the user. It is not designed to be decompiled. But apparently you can download and buy tools that can "unlock" an MDE ...

13. how to include *....*.jar file    coderanch.com

i've searched these forums and i've got nothing. So here it goes. Trying to connect to mysql using the proper drivers. Now i know i can add the jar file to the classpath, but is there a way to include the jar file within the source code, and simply use it from there, so as to always have it with the ...

14. Properties File reading    coderanch.com

Dear Ranchers, I'm doing a project in JSP and MySQL. For the JSP-MySQL connection , I'm now writing the connection statments in each and every time when I want to insert,delete, update of select the database queries. If I change the MySQL root password, it will affect the coding completely.. So Instead of that I want to put properties file to ...

15. Doubt in send the data from a text file    coderanch.com

16. Problem with getConnection() after exporting project to a jar file    coderanch.com

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at DatabaseToTable.getConnection(DatabaseToTable.java:61) at DatabaseToTable.(DatabaseToTable.java:187) at DatabaseToTable.createAndShowGUI(DatabaseToTable.java:279) at DatabaseToTable.access$0(DatabaseToTable.java:272) at DatabaseToTable$1.run(DatabaseToTable.java:293) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at ...

18. File type mdbfdt- read    coderanch.com

20. spliting the file    coderanch.com

21. Retreving PDF File from Database using Java    coderanch.com

public void openFile(){ try { st = con.createStatement(); rs = st.executeQuery("select img from image"); int i = 1; blob = null; while (rs.next()) { blob = rs.getBlob("img"); } input = blob.getBinaryStream(); output=new FileOutputStream("C:/Users/Aravind Prassad/Documents/FromDatabase.pdf"); byte by[]=blob.getBytes(0,(int)blob.length()); output.write(by); } catch (Exception e) { e.printStackTrace(); } finally { try { con.close(); } catch (java.sql.SQLException sqle) { } } }

22. HOW TO Upload files to db (postgres) using java/jdbc    coderanch.com

By "upload", do you mean to store it as a whole? If so, that's what BLOB type attribute are for. That's supported by the Statement and ResultSet classes, so if you have the file contents in your Java code, it shouldn't be too difficult. What do you have so far? As an aside, storing binary file contents in a DB isn't ...

26. context file    coderanch.com

Hello, I am using JSP with Derby on Netbeans, and I want to fix my context.xml file so I don't have to connect on each page idividually. I'm not quite sure how to edit the context.xml file so that it specifies the url of my database location. Also, I'm not sure how I can open a database connection in my project ...

27. Apache commons dbcp - SocketException: Too many open files    coderanch.com

is it possible something that would be using the commons-dbcp is not closing its connection, so the use of the connections grows indefinately. if you have not set the "maxActive" property of the BasicDataSource, i think the pool would grow indefinately until the database or file handles resource gets exausted. another option, if mysql was closing connections after some amount of ...

28. Reading excel file using java    coderanch.com

29. saving record into my database file    coderanch.com

i do have a case study its actually a file manipulation program, the file manipulation screen has save and insert command button on it, what i did is i use ActionListener event to these buttons but what should be the code in order for me to save a specific record that i wanted to add into my database file. i hope ...

30. Reading a huge file and dumping in DB    coderanch.com

I have a file with around 10 million rows. Currently a SQL server utility (Bulk Insert) reads the the file and places it in a temp table.Another SP reads the temp table data,massages it and updates it in the final destination table. The same functionality needs to implemented using Java. Following is the approach which i am thinking of: 1. A ...

31. Implementing i18n using Database instead of Properties file    coderanch.com

I am posting my question about implementing Internationalization on this forum as after searching all forums, I did not find any better place to ask this. If moderator or anybody has better idea about placing the question in correct forum, I will be thankful. I am working on a project which needs to be functional for users in several different countries ...

32. read text file and save data into database    coderanch.com

i wan't to know that if i write all the data in another data into text file and then i want to read from the text file and save the database in another database. how i have to write this program to read data from the text file and save the data into another database hope anyone here can give some ...

33. Implementing File Based Database system in java    coderanch.com

Hello All, I am going to create own File based database system.(In this we use flat .txt files to store our data.) Please tell me how can I verify my query in java against the sysntax. Currently I am thinking to use regular expression for queries to be verified but its is too hard to write the regular expression for all ...

35. Reading HTML files from a database    coderanch.com

1. You need to set the response content type before sending any data. 2. Getting a connection in the init() method is a very bad idea. If the database closes that connection you have no way to re-establish it, and there are many other problems. There are various connection pool packages that handle this problem. Bill

36. Retrieving image file from the database and displaying in the browser    coderanch.com

hi, I had done the very same thing in my last project.. after doing some R&D on blob i found a better option was to use long raw instead.. store the image in the database as long raw and just read and write it as byte array and display as it is on the browser.. ull get the desired results too ...

37. Parsing and Saving of the file to the DB    coderanch.com

Hi, I have a csv/excel/doc file that user is submitting from the jsp form. Here is the format of a file: "hi" "how" "do" "I" "do" "this" "12345" I then need to take each token and save it to the appropriate column in the DB. What are the API's I need to use for that? Does anyone have similar code available? ...

38. File Upload Problem(Database and Dirctory)    coderanch.com

Dear All, I using oreilly's MultipartRequest for file upload. I am reading the file from Servlet stream first and inserting it into DB , now I want this file to copy into AppServer's directory also , but I m getting error "Corrupt form data: premature ending". It seems my same stream is being used for Upload to directory and writing in ...

39. utility class to load files from db: static or not?    coderanch.com

Say my web users need to load files out of the database, etc. So a servlet goes to retrieve a file by ID and asks a utility class to execute the SQL and return the file back to the servlet, so that the servlet can then hand that file to the user. Should I make that utility class static and have ...

40. Uploading Flat file in the database    coderanch.com

Hi, I am doing one project in Sevlet with JSP. Oracle 9i is the database and I am using JRUN 4.0 Server in Windows 2000 Professional. What I am trying to do is, uploading a text file(may be notepad or textpad) that contains the record. I have written the code in servlet an jsp for reading the records in the flat ...

41. Storing user infos: text files vs database approach    coderanch.com

Guys, a general question: what are the pros / cons of the two approaches described in the subject? Say that I have a website with a servlet, and say that each user can store on my server some infos (for example, an agenda). Now, everyone seem to suggest that using some form of database is the approach to follow. What's the ...

42. Loading a large file into database    coderanch.com

Just curious how a web application gets a 50,000 line file. Does the user upload it? I'd look first to see if the database comes with any batch import utilities or if you have third party utilities available. Failing that, if the file is sorted on a "primary key" field, I'd query all the keys from the database and use the ...

43. JDBC Err while running jar file    coderanch.com

Hi All, I am having an application (in Jar file)which will insert records into oracle DB. this application uses swings. i am getting an jdbc connection exception when it is used to insert to DB. i am using eclipse to create a jar file. pls help me how can we go abt it. thanks & Regards, mahesh p

44. Path to store Embedded Database files    coderanch.com

I am making an application with embedded database. This application will be Swing based and it will be a single jar file. So my aim is that everything should happen in the jar file. Since I am using embedded database i want all my databse files ot be in the jar files. I am creating a folder/ package say "database" in ...

45. Read configuration from database instead of a config file    coderanch.com

Hi Friends, I have been working on stand alone application that reads application configuration from properties files. I was thinking if it would be a better idea to store them in a table in the database. This way, changes would be propagated faster if we need to update a particular property, we don't necessarily have to go through the whole release ...

46. how to set the the URL of database directly from the database.properties file    coderanch.com

Hi, I am writing Unit test to test the DAO operation. For that I need to set the data source . I am doing that by using ds.setDriverClassName("someClassName") ds.setUsername("userName") ds.setPassword("userPassWord") ds.setUrl("urlOftheDataBse") dao.setDataSource(ds); Is there any way that we can set the data source directly from database.properties file (specially the URL). So, whenever there is any change in the URL of the ...

47. copying file into database    coderanch.com

This is the gist of what I am trying to do: - I need to read a PDF file located on my machine through my java program. - The PDF file needs to be then converted into a byte array - The byte array then needs to be inserted into a (MS-SQL) table field (type=image) - The PDF file then needs ...

48. export data from db and put it into xml file    coderanch.com

Hi guys, I have a question which I have struggled four hours without solution, can anyone kindly give some advice, now it is busy exam time and i don't have more time for figuring this out. I have an example xml file as follows: learn java tina c++ peter I convert the ...

50. displaying a binary database file    coderanch.com

51. Implementing File Based Database system in java    coderanch.com

Hello All, I am going to create own File based database system.(In this we use flat .txt files to store our data.) Please tell me how can I verify my query in java against the sysntax. Currently I am thinking to use regular expression for queries to be verified but its is too hard to write the regular expression for all ...

52. which is best solution to store wave and doc file?    coderanch.com

You can use a database. Ultimately this will just store these files on disk too, though in a differernt format. There is an overhead getting BLOBs in and out of a database, but it has the advantage of being a transactional store. The file system is not transactional, so data loss is possible, plus you will have issues with concurrency. In ...

53. Retrieving xml file from database    coderanch.com

Hi Everyone, I am storing a xml file in the table. When user requests for the file i need to display the xml file from the table. I am using microsoft access database because ours is a very small application.Please let me know how to read the file and display it to the user in the original format. Regards, Nirija

54. get files from database    coderanch.com

Hello! I want to make a litle backup tool in java.I made a sample java class that stores files in mysql database: public class SaveFileDB { public static void main(String[] args) throws SQLException { Connection conn = null; String url = "jdbc:mysql://localhost:3306/bak"; ResultSet rs = null; PreparedStatement ps = null; FileInputStream fis; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(url,"root","1234"); String fileName = ...

55. uploading a word doc/excel files    coderanch.com

58. File Dsn Problem?    coderanch.com

59. how to make jar file for database dependent java application    coderanch.com

i was able to make and run the jar file for simple applications in which database involved. In the same manner I made jar file it is running but not saving the data in the database. how can i made the jar file which connects the database and what are the files have to included in the jar file

60. Can we use Excel file as a database in java?    coderanch.com

You can, yes. But you shouldn't, no. Excel isn't a database. It's a spreadsheet. Accessing it as a database would only lead to trouble. Use the appropriate API to interact with Excel files. Commonly used one is Apache POI HSSF/XSSF. Alternatively, if your sole purpose is to have an embedded database in your application, then look for JavaDB (included since JDK6), ...

61. DBCP jar files    coderanch.com

63. Access database from a class file    coderanch.com

Hello All, I am currently building a mini programme which connects to Oracle database. I have tried several ways and they are all successful. The ways are: 1) Connection to database and query to database in a single jsp file with action in a different html file 2) Connection to database and query to database in a single class file with ...

65. import data from large csv file. Help.    coderanch.com

I am working on a project where I have to import the data from a large (50meg) Excel file into a JavaDB. First I converted the .xls file to a semicolon delimited .cvs file. Originally I was using a buffered queue to read the file line by line. Each line being a row. Like this: public String[] loadSpreadSheet(String filename){ try { ...

66. working with Excel files    coderanch.com

67. problem saving the content of a file to a NClob column    coderanch.com

Hi, I'm using jdk 5.0 and i'm trying to save the content of a file to a column of type NCLOB. If the file is smaller than 4 Kb then the content is saved. If the file is bigger than 4Kb then the content is saved compressed or something ... it's not readable. The code is something like ... public class ...

68. In Java program how to export data from database to text file    coderanch.com

As i got this topic, i am posting my question in the same topic. I am able to retrieve the records from the database but i am not able to write it to the text file, so what could be the reason. I am posting my code as follows: while(rs.next()) { GetterSetter getset = new GetterSetter(); getset.setUserId(Integer.parseInt(rs.getString("cid"))); int i= getset.getUserId(); try{ ...

69. How to convert dictionary words from .txt file to database?    coderanch.com

I am learning Java and i know basic java and oo technologies and learned how to make windows. Also i know to work with databases and servlets. I graduated for bachelor on databases. Now i would like to make english-serbian dictionary in java. I have words in .doc file but i copied these words from .doc to .txt. How i have ...

70. JNDI lookup in standalone jar file    coderanch.com

71. manipulating the database in .txt file    coderanch.com

72. JDBC jar file issue (Mac)    coderanch.com

73. creating a database file    coderanch.com

75. Mysql-Jar file    coderanch.com

76. CSV file    coderanch.com

77. PDF file    coderanch.com

78. light weight in memory database with the option of saving to csv/xml files    coderanch.com

Thanks a lot. I saw it and a few others on the web but needed some advice to trust this. I see that its good and supports both in memory tables and tables in simple csv files. How about SQLite. I read about this and see that this is also widely used for the same purpose. Its used by a lot ...

80. storing xls files into database    coderanch.com

81. Accessing an HSQL file-based database inside a .jar    coderanch.com

Found some info in this thread: http://sourceforge.net/projects/hsqldb/forums/forum/73674/topic/1481509 My database was actually "appDb" in camel-case, and apparently HSQLDB does not support camel-case in resource mode for some reason. After fixing that, I was getting the following error... 20100805.165741.589 INFO Logger (?) - Database closed 20100805.165741.591 FATAL Logger (?) - could not reopen database org.hsqldb.HsqlException: file input/output error null exception message /com/company/example/db/db.script.new at ...

82. network dissconnection while copy file data in database    coderanch.com

HI, I want to copy a file from FTP server and later i want to copy the content of the file in the database which is there on another server. During these processes if there is any kind of network failure HOW can i find out and handle these kind of situations? Need advice. thanks you

83. network dissconnection while copy file data in database    coderanch.com

HI, I want to copy a file from FTP server and later i want to copy the content of the file in the database which is there on another server. During these processes if there is any kind of network failure HOW can i find out and handle these kind of situations? Need advice. thanks you

84. how to convert data to xml file    coderanch.com

85. Uploading file in a database    coderanch.com

@Jeanne Boyarsky I had this code...Here file name is given in the servlet itself.But what I want to do is to retrieve the name of the file from the jsp page and use the following code..Why can't I do that? import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class ImageInsertInTable extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, ...

87. Downloading a binary file from DB    coderanch.com

88. How to store & retrieve a video file from database?    coderanch.com

You can store binary files in BLOB's in the database. Most database designers, though, do not put large files in a database since they tend to outweigh the structured data. For example, if you have a 100 tables that are under 10 megs, and a table with gigabytes of data, backing of the entire database means you need to be able ...

89. JDBC not included into jar file?    coderanch.com

Hi there, was wondering if anyone could help me. I developed an application which works with MySQL using JDBC. It all works fine, but when I try to create a JAR file for my program, the code that uses mySQL seems not to be included into the jar file! I added code for displaying messages in different parts of my code ...

91. Writing a .csv file from.mdb file with Jackcess    coderanch.com

Hi guys, I am writing a java application that will write the data in the access database to a text file. My code looks like this: package Harvest; import com.healthmarketscience.jackcess.Column; import com.healthmarketscience.jackcess.Cursor; import com.healthmarketscience.jackcess.Database; import com.healthmarketscience.jackcess.Index; import com.healthmarketscience.jackcess.Table; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Iterator; import java.util.Map; public class Test { public static void dumpDatabase(String sourceFilePathWithName, String destinationFilePathWithName) ...

92. to read a file and store it    coderanch.com

public class AccountDetails { public static void main(String[] args) throws SQLException, IOException { ExtractData ed = new ExtractData(); File file = new File("/home/tsuser/new_bank_records.txt"); FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); String line = br.readLine(); String[] data = {}; data = br.readLine().split(";"); while (data.length != 0) { ed.insertData(data); data = br.readLine().split(";"); } } }

93. [ASE15] The file x contained in the jar does not represent a valid Java class file    coderanch.com

Hi, Using instjava to push java classes to server side (sybase ASE 15) in order to use sqlj, I've got the following error whatever the jar I use even the one provided in sample (http://www.sypron.nl/udf_prt.html). << The file 'xxxx.class' contained in the jar does not represent a valid Java class file >> C:\>instjava -f c:\DateTimeFormat.jar -U sa Password: Server Message: PC ...

94. jar files in Eclipse    coderanch.com

Thank you for the reply....Actually I am doing this project where i am using spring with JDBC. I have imported most of the jars from common logging, commons-pool, dbcp also but its still giving me this error: Apr 11, 2011 1:48:33 PM org.springframework.context.support.AbstractApplic ationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlAp plicationContext@133f1d7: startup date [Mon Apr 11 13:48:33 IST 2011]; root of context hierarchy ...

95. Reading from a XML file or from Database ?    coderanch.com

I would like to create a XML file storing a SQL stament which could be changed time to time manually and I would like to read it inside a Web Service application. By doing that, I do not want to start the Application server and get customized SQL inside my Java Classes on Web Service Application. Only changing the XML file ...

96. How to store an XML file as a string in database and retrieve in Java code    coderanch.com

Are you looking for any realtime project or just for learning purpose? There are many databases that support this feature; well I can tell you what i have worked on Use Oracle 9.2 onwards (i think even 8 should also support but i never worked on that) declare that XML column you want to store as String as CLOB use Oracle ...

97. comparing csv file values with database attributes.    coderanch.com

If you are using Oracle, then you can use external tables. Basically, Oracle external tables allow you to define a SQL table structure over a flat file e.g. in CSV format. Because this looks like any other table inside Oracle, you can then perform SQL operations on the table e.g. to compare its contents with other tables in your database. Generally ...

98. Issue with entering data from Java class file to Database    coderanch.com

I am using a Java class file to read data from an Excel sheet using the Apache POI API,and then using Preparedstatement to finally enter the data into database.Now I am using an insert statement in a for-loop that enters one set of data at one time. Somewhat like this.... String query_insertion = "insert into temp_emp_number values (?,?)"; PreparedStatement pstmt = ...

99. Upload file or pdf in database with its extension in separate column    coderanch.com

I am able to store files in the database. The fields in the database are id, name( of the file as varchar), type(file extension as varchar) and content(as blob). While retrieving from database, i want to display just the id, name and extension in jsp page in table form. That can be done very easily. But what i want to do ...

100. Unable to create jdbc instances as per the value set in the properties file... please help me    coderanch.com

I want to create minimum 'N' no. of pool instances. I am passing the value through a properties file and injecting into the "OracleOCIConnectionPool" class which extends "OracleDataSource". in the "ojdbc14.jar". But when I run the project it is creating N/2 pool instances instead of N. Please help me on this. Thanks in advance.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.