jdbc 5 « Database « Java Database Q&A





1. Synchronizing two databases!    coderanch.com

Hi all! I have two databases in my application, one is a server side database, the other one is a local database. My client must work into online mode (server db) or offline mode (local db). When offline mode is chose, some tables from server side must be downloaded to allow the client to work in offline mode. When he turn ...

2. excel as a database    coderanch.com

Victor, Welcome to JavaRanch! Is that "other computer" a server or someone else's PC? If the later, do you have a requirement for what should happen when the other computer is unavailable. If the Excel file is in CSV, you can just use Java parsing. If it is a true Excel file, POI is good for reading. I agree with Ulf ...

3. back up database    coderanch.com

5. How can we store the values in the DB    coderanch.com

Hi All, How can we store the value in the Data Base with the 0's in the before the number. Ex:I have a number in the Db with value 36 , I want that value to be stored as 00036 in the DB.Can any one help me to do that. Thanks in Advance, Mastan.

6. Storing Kanji charaters into database    coderanch.com

Hi all, I am trying to store a String into database that contains some special japanese charaters. The field on the database side is VARCHAR2(4000) So, from the java code if String has more than 4000 cahracters am taking first 4000 characters only. if(str.length() > 4000){ // Take first 4000 chars only } This logic did not satisfy the field restrictions ...

7. Can we store Objects In DATABASE..?    coderanch.com

8. database    coderanch.com

Creating a database connection using JDBC involves 3 main steps. 1. Loading the database driver 2. Getting the connection using the driver manager 3. Using the connection to access the underlying database. The sample code below explains the steps in detail. import java.sql.*; Connection conn = null; Statement stmt = null; ResultSet rs = null; try{ //Load the database driver class ...

9. database engine that can be used in mac and windows JDBC    coderanch.com

Welcome to JavaRanch. Are you looking to embed a database in your application? Or do you merely want to access a database that is installed on a server from various client operating systems? If the former, have a look at Apache Derby; if the latter, just about any database will do (Postgres, MySQL, SQLServer, Derby, ...) since the database drivers for ...





10. Database installation??    coderanch.com

11. database access pattern    coderanch.com

Hi everybody, while writing a multithreaded UI application to access a DB I came up with a question I haven't managed to answer yet... please have a look, any hint would be greatly appreciated :-) I have a DB table: Customer(ID, name, surname, ...) where ID is a primary key automatically inserted by the DBMS (e.g. autoincrement SQL Server or sequence ...

12. webapplication with several databases    coderanch.com

Dear Java-Ranch-Folks, I hava a running webapplication with tomcat6. It consists of several tables in one database which is defined as a JDBC Data Source. The application is a content management system where you can create new workflows (tables), upload data together with text comments in the individual cells of the tables. All workflows are project related. Now in our company ...

15. how to add program arguments to database    coderanch.com

how to add program arguments to database I had created pankaj.java file in which I created database connection and stores values to ABC table. But instead of inserting hardcoded valus to table I want to insert program arguments that I will supply through command line. Anyone knows how to do this. I am using MySQL 4.1. The code for pankaj.java *************************************************************** ...





17. Java DB Project    coderanch.com

Hello Everyone. I have a couple of questions and would like to hear your thoughts and get your feedback. I am planning on developing a Java app that will act as a front end to a database and present the end user with various questions regarding the db contents. For example, the GUI front end should present a question like: "How ...

18. Storing a List in Database    coderanch.com

Hi, I wanted to have a table which has some messages stored with following columns: MSG_ID MESSAGE POSTED_BY I want to maintain a list of people who have read this message, who ever view the message will be submitting the confirmation that they have read it. Now I want to link this table with may be a List which would tell ...

19. Database novice: Suggest recommendation    coderanch.com

20. Database    coderanch.com

21. Database Normailization???    coderanch.com

22. help! Java desktop application database    coderanch.com

23. Database cannot be connected    coderanch.com

24. Caching of Database Access Objects's possible?    coderanch.com

I am working on a web application. I am using Struts for the presentation layer. Also I am using DAO pattern for Database layer. My doubt is about creating instance of DAO's. I am created a DAO Factory which can create instances of DAO's. Whether I can go for caching of DAO or Do I have to create a new DAO ...

25. need how on how to create a database    coderanch.com

hello everyone i need you help with the following questions i am tryig to create a database for my project with the following informantions. the database is on a accident log database of a police station listing - car imformation - car registration - times car been involved in accident - drivers informations - types of accidents - fine or purnishments ...

26. Handling a database shutdown within java    coderanch.com

Hi folks, I am writing a really simple java application that is meant to act like a daemon. Basically it queries a database constantly, and sends the results to a stored procedure. So, my question is this: Since my java code needs to run constantly, how can I get it to handle database restarts successfully? Is there a method I can ...

27. Unable to Access the Database    coderanch.com

Hello, I am trying to connect the database(Oracle 9i) with my Frontend(J2ME)using Tomcat 5.5. I am trying to login into the system where I placed all the user names and passwords in a table of the database. I used Servlets to access the Database using JDBC-ODBC Connectivity. When I run the URL from the browser I am not getting any reply ...

29. database access problem    coderanch.com

30. Access Database Dump    coderanch.com

Use the built-in database export/import commands (or in the case of Access, copy the file). There's no such tool that will magically dump your database into a file format because database organization may be extremely complicated, especially the more your data is normalized. For example, let says instead of US States in an address table, you have a StateId which refers ...

31. Creating Database    coderanch.com

32. Stubbing a database for unit testing    coderanch.com

Depends on what you are unit testing. If I wanted to Unit test the actual SQL (does the SQL do what I think it should) I would use DBUnit to put the database in a known state and make sure I got back the data I wanted. If I wanted to test some DAOs and make sure the correct SQL was ...

33. database tool    coderanch.com

34. Get Alert From Database    coderanch.com

Ulf Dittmer , Currently my desktop application checking the DB every 1 minute once.But I want to change this logic. Because some times the changes in the database will happen two days once. So I need to identify my java application once the DB gets updated. Any other way is there? Thanks, Suresh Kumar.K

35. What database should I use?    coderanch.com

Hi, I am working on a desktop application which requires really robust database support. By robust, I mean it should remain consistent even if the power cord of the PC is taken out all of a sudden. Of course, the transaction that was in the process of being written to the files may be lost but at least it should not ...

36. Database modeling problem...    coderanch.com

Hello, I am faced with a database modeling problem which is as follows: I am designing the web site for a sculptor and I have a sculpture table that contains several sculptures (width, height, depth, title, description) each sculpture tuple/row has several photos hence another table: the photo table and so on. The problem is with what I call "residual" information ...

37. Need more values from Other DB    coderanch.com

Hi ranchers, I am back with bunch of questions... I have lot of tables like customer,vendor,item and rma table... I generate a report of products that were return by customers to our company.. Here in this table i had a item_id field which is an foreign key which is the primary key of item table...My problem when admin clicks the report ...

38. DB problem    coderanch.com

Hi guys, i'm facing a weird problem with oracle db ,i'm trying to connect ot it to get some data then put this data in Vector to use it later , the problem is sometime the db staty without retriving any thing so i check the sql statment it;s ok , i check the db connection it's ok , so i ...

39. Counting identical items in DB    coderanch.com

40. how to create database in ms-sql server using java/jdbc    coderanch.com

hi, this is siva and this is my situation.. i need to create a database in ms-sql server using java/jdbc .the database creation script will be in .sql file. we can create the database with the help of osql commands if the local system is installed with ms-sql server. but i need to create the database on the remote system without ...

41. Distributed database    coderanch.com

42. Putting Database values in JavaBeans    coderanch.com

I am not sure you have posted complete problem. Correct me if I am wrong, the counter table has a column named count as integer type then there would be many count count unless you add something in your where clause. so how do you want to hold them in single variable ? What is your exact problem ? Shailesh

43. using a local database    coderanch.com

hi, i'm kinda new to databases in the java world. I began serching a way to connect to databases in java, specially ODBC and all i could find out was connecting to remote databases using an url to identy them. Is there a way to connect to a database that i have in my computer an bound the file with the ...

44. Storing Hypen in database from java    coderanch.com

45. recent entries from the database    coderanch.com

46. JDBC and database    coderanch.com

Hi Jasbir, Try the following: public void executeConnection(String firstName, String lastName, int id) throws Exception { Class.forName("oracle.jdbc.driver.OracleDriver"); String url="jdbc racle:thin:@myServer:1521:mydatabse"; String user="Scot"; String password="Scot"; String name="Jasmin"; String sql = "select ?, ? from employee where id = ?"; Connection con=DriverManager.getConnection(url,user,password); PreparedStatement pstmnt = con.prepareStatement(sql); pstmnt.setString(1,firstName); pstmnt.setString(2,lastName); pstmnt.setInt(3,id); ResultSet results = pstmnt.executeQuery(); } Use a PreparedStatement instead of a Statement. PreparedStatements are ...

47. access database in java    coderanch.com

48. access database with java    coderanch.com

Now on to your question. Can you share the query contents? This will help us give more specific advice. That said, two things really jump out at me: 1) There is an unnecessary SQL call in here. You really only need to do one call - the query itself. If you put the contents in an ArrayList, you don't need to ...

49. Complete database newb any help appreciated:    coderanch.com

I've written a small program to teach myself new Java concepts and I am ready to implement a DB. I've decided I'd like to start off using a Derby DB and use JDBC to speak with it. Are there any great step-by-step tutorials out there that cover the following main points: - How to create a Derby DB (I already know ...

50. Regarding Database Index    coderanch.com

No. Nor should it be. Indices incur a decrease in insert/update/delete performance so you wouldn't want them added by default. Some database s (such as SQL Server) will automatically create indices on columns that are foreign keys. Other than that by and large its up to you to choose what to index.

51. Database BackUp Using Java    coderanch.com

52. Facing Problems with DataBase    coderanch.com

Dear all, I am facing the problems while i am connecting to the Oracle DB. Here, on first time i am used type1(sun.jdbc.odbc.JdbcOdbcDriver) driver on that time i am successfully fetching the records from DB. But i am not able to inserting the recording into DB. While inserting i am not getting any error on browser. Browser keep on showing the ...

53. Creating a database from Java Source Code    coderanch.com

Hello, I'm trying to develop a local database using derby/JavaDB. I've created a txt-file where I have the DDL-Statements to create the database and a txt-file where i initialize the tables with INSERT statements. I think I've found a solution how to load these txt files from Java and execute them here on the board. Execute file My question is, what ...

54. Advantages of Reducing Database Hits    coderanch.com

The project that I am working on connects every end user to the database. We are using OracleOCIConnectionPooling for the logical connection. The issue here is for the error handling we are storing the error messages in the database. My question is " Is is good to load all the values at the application startup " so that it doesnt have ...

55. Databases    coderanch.com

56. How to store a check box in DataBase??    coderanch.com

Your question should be rephrased as "how to store an array in database". You dont store checkboxes in DB. Well, the answer is obvious: insert each value of the array in a new row in database. If all values are to be related to a single entity, then you can use a so-called chain table for this which you can later ...

57. How to pass arrays using JDBC to database?    coderanch.com

You can store Java objects serialized in a binary field of the database. But that's a bad practice and bad datamodel. You're going to tight couple Java with a RDBMS. I wouldn't recommend that. Just create a chain table where in you insert every entity as a new row referenced with a foreign key to the parent entity -if any. You ...

59. How create API for DB application.    coderanch.com

60. how to access names of different databases    coderanch.com

hi all, i use MySQL database. suppose i have created multiple databases with create database command. i can access name s of the tables in a particular database. but i want to access the names of different databases that i have created. i dont understand how to do that. please guide. thank you.

61. Why DB Visualizer?    coderanch.com

absolutelty, with free download of toad you can view/edit stored procedures execute multiple sql statements without having to comment out other sql statements bu highlighting the sql you need to execute create scripts for tables/sequences etc create sequences from the drop down menu instead of writing the whole syntax yourself and the list goes on ..... you cant do all the ...

62. DB Visualizer: for which RDBMS was it created originally?    coderanch.com

Gian, Back in 1998 when the first lines were written, Oracle was the database it was tested with. The initial purpose was to graphically renderer primary/foreign key mappings (also called referential integrity constraints) in an Oracle database. Soon support was added to run any SQL statement, editing table data and so on. Initially it was a free product and in 2002 ...

63. DB Visualizer Execution Plan    coderanch.com

Hi Sir, I have this query, in the company where I am working, there are a lot of Database that is being used such as DB2, MSSQL, Oracle and for stand alone MySQL and Access. Oftentimes we do cross query between different RDBMS. I want to know if DB Visualizer has some sort of Query Execution Plan where I will be ...

64. DB Visualizer: database refactoring    coderanch.com

Gian, (I wrote a rather long reply to your question, unfortunately when I pressed "Submit" i got: "Aaack! You caught us with our pants down! Here we are, tinkering with the servers and you show up. How awkward! Try back in just a minute... Sincerely, the red faced JavaRanch staff." and my reply was lost...) To summarize my reply: database refactoring ...

65. Format for reading special text from database    coderanch.com

There's a column 'filename' in MySQL which has data in the format '/home/guest/sandeep/project/Sample.txt'. I used the format LONGBLOB to store it in the database. Then my objective was to retrieve it using Java code. JFileChooser fc = new JFileChooser(); if(fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String ss = file.toString(); filenameText.setText(ss); } This code is used to store the name ...

66. problem in passing while loop variables from database    coderanch.com

Hi, I am getting records from the database and store it in a string variable inside while loop.When i tried to access the variable in another class,i am getting the top most record saved inside the while loop my code follows: class1: public class class1 extends BaseAgiScript implements AgiScript//NewIvr14 { Statement st; ResultSet rs=null; Connection conn = null;static String campaign1; public ...

67. Database Design issue    coderanch.com

Hi Ranchers, I have a database system that has 4 tables. 3 of these tables have a primary key. The fourth table has four columns, three of which are foreign keys for the other three tables. The fourth column has data. My question is that is this a proper design to have data in a join table(my fourth table). Or should ...

68. database coloumn updation problem    coderanch.com

I have written the below code in jsp. All the database coloumns are getting updated except one. this is the code <%@ page import="java.sql.*" %> <%@page import="java.util.*"%> <%@page import="java.util.ArrayList"%> <%@page import="java.util.Arrays"%> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %> Computation <% Connection connection = DriverManager.getConnection( "jdbc:odbc:BE"); Statement statement = connection.createStatement() ; String query="Select mcap,wt from Nifty"; double ovrwt1=0; ...

69. How to get connected to 2 databases    coderanch.com

Hello sir, we have developed 2 webapplications in servlets.1 application has one database and other application has other.now i want to run 2 applications from one system is there any possibility to configure both DB's in one xml file if so please let me know .I am using tomcat5.0 and also is there possibility to run 2 versions of tomcats on ...

70. Best way to access database    coderanch.com

71. Backing up a database through JDBC    coderanch.com

73. To store img in db (bytes) or not?    coderanch.com

Hi all, I have 2 strategies to store a photo in a db (in my example of user's image) 1. save the image into a local folder (and make it unique - say by the userID --> 2052.jpg) to access it I just point to the portrai_folder\2052.jpg or 2. I can convert the image to bytes (do String strDB = Base64.encode(bytes)) ...

74. Pinging a Remote DataBase    coderanch.com

75. From where should i start to learn about database    coderanch.com

One book I liked was "Beginning MySQL" by Sheldon and Moes. Although it is directed at MySQL it includes a nice introduction to SQL. My copy is however dated 2005 and MySQL has moved on a lot since 2005, but you can probably find a second-hand copy for a very reasonable price somewhere.

76. accessing database inside java code    coderanch.com

Hi, I am having a database connection string in a code as follows: package jdbc.connection; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class Jdbc { public static void main(String args[]) { Connection con = null; try { Class.forName ("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://192.168.1.77:3306/peopletech", "meetme", "meetme"); if(!con.isClosed()) System.out.println("Successfully connected to " + "MySQL server using TCP/IP..."); } catch(Exception e) { System.err.println("Exception: ...

78. Which is the best way to store the values of an ArrayList into a database?    coderanch.com

I have a set of objects that hold information about articles, for example the article's title, its author and its subject(s). The subjects are String values stored in an ArrayList. The number of subjects is different for almost every article. I want to store the values of those objects in a database (currently i use MySQL) so i can search in ...

79. Back of database    coderanch.com

80. Writing object to the Database using Externalizable    coderanch.com

c:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5\webapps\Bball\WEB-I NF\classes>java -jar "c:\Program Files (x86)\Sun\JavaDB\lib\derbyrun.jar" server start Security manager installed using the Basic server security policy. Apache Derby Network Server - 10.4.2.0 - (689064) started and ready to accept connections on port 1527 at 2009-07-12 03:26:03.708 GMT Exception in thread "DRDAConnThread_4" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2882) at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390) at java.lang.StringBuffer.append(StringBuffer.java:224) at java.io.StringWriter.write(StringWriter.java:95) ...

81. Java Database    coderanch.com

So. My question was that why aren't java databases so popular such as Oracle or DB2. I think there might be some or the other drawback due to which java databases are not used so widely. If i want to develop a database in java then which guides shall i follow. Thanks and Regards alexander

82. How do I bundle my Database Information in a stand alone Appl    coderanch.com

Hi Guys, your help is needed. I developed a Java SE Application that talks to a database tables in my computer (precisely mysql) and I have it in a jar file called MyAppl.jar. MyAppl.jar is working perfectly well in my private computer which I used in the development. But my problem now is that when I take the MyAppl.jar to a ...

83. Null or blank String into database    coderanch.com

What are the requirements of your application. First of all, it looks liek the field is nto required. If that's not the case, then validate on the client to make sure something is entered before allowing form submission. If the field is not a required field, then is the column defined as not null in the database table?

84. How to generate Auto-EIN number in db ?    coderanch.com

Hi, What i want, whenever an admin register a new user by filling up his/her details(except EIN) it should be saved in the database(iam using sql server 2005) but with Auto-generated EIN with the format say 'P1000'. Now when admin registers another one, it should be saved with 'P1001'. Please give me some idea in order to achieve this. My first ...

85. How fast can you re-connect to DB    coderanch.com

86. migrating a database to another programmatically    coderanch.com

There are plenty of off the shelf, comercial solutions but not many via an embedded library. In general, though, I've found it doesn't take much work to write one yourself for a specific task. If you use the meta data API, you can read a database and create a file of SQL create/insert commands, formatted for the new database. Then just ...

87. what are the other databases    coderanch.com

Relational databases are the most common now, you need to go back in history (or forward with Google's BigTable system) to see others. For example, some database systems store things as entities with attributes which could be open. In other words, entities have an undefined list of attributes and some entities may have attributes others do not.

89. alternate to DB connection/xml    coderanch.com

Hi, I'm writing a java app that connects to a DB on a server I have on my home network. I want to be able to dump the data as xml, and use that when I have my laptop and no db connection is available....I've been writing some code like so: if(getConnection() != null){ // do db stuff } else { ...

90. Which DB to learn    coderanch.com

There is quite a lot different between the two, but the basic concepts are the same so either are fine to learn on. Both are well suited to use with JDBC. Knowing Oracle is a good thing to have on the CV, but it is a much steeper learning curve (Oracle is a much bigger beast than MySQL). MySQL suffers a ...

91. database designing issue    coderanch.com

yes the features of same thing. actually i am parsing an XML file and then transferring its data into the database. Let me elaborate my question by giving example: suppose my xml file is the below one: 1 how's life today? its cool 10 5 7 i want to design a database to store above xml file ...

92. what database to use?    coderanch.com

93. java db on a mac-getting started    coderanch.com

Hello Ranchers. I'm an intermediate Java programmer in spare time and have been chipping away at an application that I'd like to augment with a database...and that's where the trouble starts. I'm using a MAC w/ Snow Leopard and Eclipse IDE with Java 1.6 JRE in the MAC. I'm having trouble getting going in the right direction here, so any help ...

94. DB app: complex text structure    coderanch.com

Hi, i'm writing an app that will store some xml data into a db, and the java app will render the data from the db; either as html, or some other way, the point is that there will be various kinds of text markup. So some data like this: Diary entry Today I drank around 11 cups of coffee ...

96. Comparing parameters values with db values    coderanch.com

1) I am trying to compare the db value with user values with parameter received from user 2) if the value exists then ignore and insert the values that not exists in the db Please check my code and help. Thanks in anticipation String query="select expertise from expertise where emp_id=?"; String query1="insert into expertise(emp_id,expertise) values(?,?)"; PreparedStatement ps=cnn.prepareStatement(query); ps.setString(1, emp_id); rs=ps.executeQuery(); while(rs.next()){ ...

97. database connetion    coderanch.com

hi all, have a servlet which runs sql against an oracle 11g database with Oracle JDBC driver V9.2.0.1.0. For some reason i keep getting "connection closed" exception even when i detect closed connections in the code (see below) and re-establish a connection. The app server which i have my connection pool set up in is glassfish V3 . . . try ...

98. Java discourages intelligent use of database technology: Discuss.    coderanch.com

Not trying to provoke a major conflict with all you good people at Javaranch, especially as I'm still learning lots of great Java goodness from all of you, but the above statement encapsulates a common experience I've had on several recent projects, and I'd like to see if others have had the same experience. I'm an old Oracle database developer with ...

99. handling objects with DB    coderanch.com

I have an object called vocabuary which consists of several concept objects I have a class which has methods for adding ,modifying and deleting data from DB... Now ,using vocabulary object I call this method passing the concept object as parameter... Meanwhile I create a hashmap of concepts... 'I am unable to manage my object... For example while adding data ,i ...

100. How to know when there is a chnage in DataBase    coderanch.com

Hi Is this possible . I have a table in my Oracle Database .My requirement is that whenever there is a change in the table (For example a new row is inserted or any existing data has been updated ) . I want to execute a event . Is this possible ?? Thank you.