jdbc 4 « SQL « Java Database Q&A





1. Need to know Sql version.    coderanch.com

It doesn't matter how many instances of SQL Server you have installed on one machine, they all listen on port 1433 by default. It is the instance name that tells SQL server which instance you want not the port number. NB: I think the SQL Server docs suggest installing 2000 and 2005 on the same machine is unsupported - I can't ...

2. Sync DataBases Postgre SQL and My sql    coderanch.com

So you want a hot backup of a different database type? Doing this accross two databases will be difficult; the only way I can thing is by performing every update twice from your application (and ensuring your application is the only one that accesses the database). This will require XA transactions, which is a further overhead. If your primary and slave ...

3. DbVisualizer vs Squirrel SQL    coderanch.com

Rogerio, Sorry for the delay. I missed your post. DbVisualizer is no rocket science but it is very mature and include a lot of utility features that makes DB admin and development easier. Here are some of the major feature areas in DbVisualizer include: - Schema Export with reverse engineering of DDL + export of table data - Monitor feature which ...

4. SQL Developer and DbVisualizer    coderanch.com

5. SQL help required    coderanch.com

6. Understanding of SQL Relationships    coderanch.com

7. Nested set from SQL to Java    coderanch.com

Hi there! In a Java application I am using an SQL table in Nested Set structure for saving a XML tree. The nested set structure is said to be able to rebuild the tree structure very quickly (just one select), which is exactly what I need. Now, I am trying to get the tree structure out of the database table and ...

8. import java.sql    coderanch.com

hi friends, As we know java.sql package consists of interfaces and these interfaces are implemented by the corresponding data base vendors in thier own class for example connection is an interface in sql package and these interface are implemented by oracle in their class by name oracleConnection.but when we are connecting to a perticular data base we will put data base ...

9. java.sql.*    coderanch.com

hi friends, As we know java.sql package consists of interfaces and these interfaces are implemented by the corresponding data base vendors in thier own class for example connection is an interface in sql package and these interface are implemented by oracle in their class by name oracleConnection.but when we are connecting to a perticular data base we will put data base ...





10. SQL Trim Function    coderanch.com

11. Implemenation of SQL package....?    coderanch.com

12. JDBC validating username and password against SQL database    coderanch.com

Hi People I've got a problem: I need to create a database(SQL) to store username and passwords. I've made the database. Now I need to write a Login Screen(Java application) where users can input the username and password, the Java Application needs so verify that the username and password matches the respective entry in the database, if any. This is what ...

13. sql question    coderanch.com

PreparedStatement stmt = tr.createPreparedStatement(""DBTransaction.DEFAULT); stmt.execute( "f_valid_agree_accept(1, \"856456\", '0')" ); i got the error: java.sql.SQLException: ORA-00900: invalid SQL statement 09/08/05 09:08:30 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138) 09/08/05 09:08:30 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316) 09/08/05 09:08:30 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282) 09/08/05 09:08:30 at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639) 09/08/05 09:08:30 at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:185) 09/08/05 09:08:30 at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:633) 09/08/05 09:08:30 at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1161) 09/08/05 09:08:30 at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1654) 09/08/05 09:08:30 at oracle.oc4j.sql.proxy.StatementBCELProxy.execute(StatementBCELProxy.java:301) 09/08/05 09:08:30 at ca.bluecross.ab.tao.controller.loginfilter.TermsOfUseFilter.updateTOU(TermsOfUseFilter.java:120) 09/08/05 09:08:30 at ...

14. SQL Recursion woes    coderanch.com

I have a table that stores tree structures, the tree name and nodes in the tree with their respective parent node. Here's an example: Tree Name | Node Name | Parent Node Name ------------------------------------------------------- Business | Group A | Business | Group Aa | Group A Design | Group A | Design | Group Aa | Group A As you can ...

15. Seeking help on a complex SQL I reckon, wish get a simple one from answer    coderanch.com

Hi All Another sql to ask here. we have a table File(name ,date, file_size). anyone has simple query to list name of file where the related size is not 0 let me give some sample data. name date size a 1/1/2001 0 a 2/1/2002 2 a 3/3/2003 0 b 1/1/2000 3 b 2/2/2001 4 If I run the query, it should ...

16. How to start off with sql    coderanch.com

Do you have an existing database you can work with? I find the process of setting up a database server can turn many people off since they sometimes break and require manual recovery. In short, using a database is very different from administering it, so don't get discouraged if installation doesn't go well.





17. which sql going in database    coderanch.com

18. Sql optimizer    coderanch.com

The best SQL optimizers are humans. If possible, talk to a DBA who can help you work out the issue. In general, database optimization tools may only help you find the troublesome queries, but rarely how to fix them. The vast majority of the time this involves adding an index to a particular column (Hash or Btree) I recommend find a ...

19. Snapshot in Sql    coderanch.com

20. Need some SQL Validator    coderanch.com

I need to write some big insert queries to perofrm my operation , somehow i am making some mistake in writing SQL queries like missing comma and lot of time is wasted in checking the syntax of the query . Please let me know Is there any tool that checks the syntax .

21. java sql question    coderanch.com

22. SQL Trigger failure    coderanch.com

Hi! Could someone please tell me why sql trigger in the below code fails. Please guide me with corrected trigger code. Database is Java DB. Thanks in advance! drop table two; drop table one; create table one( ssn int, primary key (ssn) ); create table two( ssn int, foreign key (ssn) references one(ssn) ); insert into one values( 1234512345 ); select ...

23. Sample SQL question    coderanch.com

25. SQL problem    coderanch.com

Hi, I have a problem with designing a database, basically suppose there is a table STUDENTS containg SURNAME, FORENAME, AGE. And say there is a table ATTENDANCE When a student logs in, the ATTENDANCE table inserts a row of data that includes the STUDENTs SURNAME. Now suppose the student changes their SURNAME, by using UPDATE... My problem is that in the ...

26. Collumn names in sql request    coderanch.com

27. SQL help    coderanch.com

Hello everyone, I have a problem with order by clause. My table has 2 columns: type and country. select type, country from test_pnl_report type country ----------- -------------- Bank Debt United States Bond Future United States Bond Future United States Bond Future New Zealand Bond Future Canada Bond Future United States Bond Future Japan Bond Future United States Bond Future Japan Bond ...

28. variable name for where clause in sql    coderanch.com

hi.. I am doing a jdbc program connecting a server and a client. I type in a value from client which is received by the server.Now the server reads in the value typed and stores in a variable. Now I use this variable to access the database(oracle 10g) with the help of select where clause which equates to a variable(not literal ...

29. tool to generate sql ?    coderanch.com

30. java.sql.SQLException-Need help to resolve.    coderanch.com

Hi, I am using mysql database. I have loaded the temp table with user info from the registration screen. If the user is approved, i need to load the base table with the pre-loaded data from the temp table. email-id is the username so i am doing the check against it. But i am getting java.sql.SQLException: You have an error in ...

31. SQL sintax    coderanch.com

Guys I am having the following problem: When I use Sybase database I get to do this: select * from DatabaseCars.. TableKindOfCar it is the same to select * from TableKindOfCar however you must be into that Database else does not work but in my Mysql it does not work... bye, Andr AS

32. java.sql getTimestamp    coderanch.com

You should bear in mind that we don't know what your PreparedStatement looks like. And that we don't know anything about this table and what type of column you're trying to use. (Actually, not true: we know it's in an Oracle database.) So absent that useful information I would suggest you try to insert it only in a column which is ...

33. help with basic SQL    coderanch.com

34. How to SQL Dump?    coderanch.com

35. SQL question    coderanch.com

Dear all, Supposed that we have a table Person that contains two column (Name, Car). Supposed that we have 3 kind of car: Car1, Car2, Car3. How can we count the number of each kind of car that a person have without using 3 different separated SQL queries like that: Select Name, count(*) from Person where Car = 'Car1' Group By ...

36. Repeatable SQL    coderanch.com

Hi I have a requirement like this below. Table A contains data as below. id Name Tasks 1 test IA 2 best ABC 3 zest IA 4 east BCD 5 west IA Now column id is a foreign key referring to column cid in table B cid Name 1 test 2 zest 3 east 4 west Now my requirement is to ...

37. SQL - correlated subqueries    coderanch.com

I'm asking this because I want to know if this is something people actually use. I'm using the O'Hearn SQL Certified Expert exam guide and I think either the example is not good or the description is worse... So here's the example O'Hearn gives for a correlated subquery (page 361) SELECT A.SHIP_CABIN_ID, A.ROOM_STYLE, A.ROOM_NUMBER, A.SQ_FT FROM SHIP_CABINS A WHERE A.SQ_FT > ...

38. SQL current year    coderanch.com

39. SQL return substrings    coderanch.com

40. Java and SQL    coderanch.com

Hi, i don't know where to ask the problem so I'm asking here. I need to delete some 5000 entries from oracle database through Java. First approach was to create prepared statement with delete query and then delete one by one. But this approach is not efficient as entries might got 10K and is not constant. Is there any other way ...

42. sql book needed    coderanch.com

43. Another SQL Question: Union/Union All    coderanch.com

Okay, another practice question courtesy of LearnKey for the SQL Expert Exam SELECT NAME FROM (SELECT 'JOE' NAME FROM DUAL UNION SELECT 'MARY' PERSON FROM DUAL MINUS SELECT 'JOE' DIRECTOR FROM DUAL) UNION ALL SELECT PERSON FROM (SELECT 'MARY' PERSON FROM DUAL UNION SELECT 'LENNY' CLERK FROM DUAL) The question is "how many rows are returned?" My logic was 2. One ...

44. [SQL] varchar2 to number    coderanch.com

Hello guys, In one of my tables, i have a varchar2 column. This column contains numbers and null values . (hm yeah..) I'm trying to compare this field with some constant such as "column > 50". I tryed this : SELECT cl_pct_ci FROM myTable WHERE id = 2; -> 55.555555556 SELECT to_number('55.555555556','.') FROM dual; -> "Nombre non valide". SELECT to_number('55.555555556','99.9999') FROM ...

45. need help implementing the Union operator(SQL) in java    coderanch.com

Thanks. I'm actually using java to implement the Union operation of SQL. I have checked the two tables in question for compatibility i.e the attributes and their corresponding data types match completely. Now, I need to combine the data tuples of both these tables to one. Any in-built functions in java that could help me do it?

46. SQL Amtipatterns smoketests?    coderanch.com

47. SQL Antipatters and db refactoring    coderanch.com

Hi Gian, The Sadalage/Ambler book "Refactoring Databases" is more or less a catalog of the types of schema changes you might find yourself making, and how to make each type of change successfully. Often we use database refactoring to more faithfully represent our data model. For instance, a users table has phone_number, but if we decide users can have multiple phone ...

48. SQL antipatterns: do you talk about OLAP, MOLAP, ROLAP,...?    coderanch.com

Hi Rogerio, I didn't delve into data warehousing, MOLAP, or Dimensional Modeling (DM) in my book. Date warehousing leads us to use denormalization techniques to optimize the database schema for certain types of reporting. Instead I covered standard relational design, with normalization being the default, which is better for OLTP or OLCP type applications. Overall, my book tries to address the ...

49. SQL Antipatterns    coderanch.com

51. SQL Antipatterns question    coderanch.com

I have recently read another SQL Antipattern book; most, if not all, of the data structure issues described would go away if a proper normalization (to normal form 3) is performed. So here are my questions: - are there any database design Antipatterns that go above NF3? - Is query concatenation (instead of parametric query) an antipattern? - Another antipattern I ...

52. SQL Antipatterns question - Database programmers vs Software programmers, the role of ORMs    coderanch.com

As a software developer, I always feel a little embarrassed for myself when I have to write some SQL and forget how to do something basic like an inner join. Do you think it's possible to be both a good database programmer and a good software programmer? Or are the two domains too complex for any one person to be an ...

53. SQL antipatterns: decisions on business logic    coderanch.com

Hi Bill, I'm not sure if this is a good question given that the title of your book mentions SQL explicitly...but anyway... Does your book also elaborate solutions concerning application design in general, but in particular those decisions regarding for example whether to put business logic in the database (e.g. with PL/SQL) or not, when to do so, when not...etc.

54. Is this an SQL Antipattern?    coderanch.com

So in Joomla! 1.5, just about every table has a "params" column that's basically a newline-separated list of "key=value" pairs. I've written a Hibernate type to expose it as an instance of Properties, and Postgres and MySQL "C" stored procedures to make it easier to parse a value from that column. There's not much I can do about Joomla! (there are ...

56. Mobile SQL    coderanch.com

Dear All, Kindly want to ask if we can have in j2me a mobile database, i want to write simple SELECT statement (ex: SELECT * from emp;) and retrieve the employees so is that possible to write a mobile application do that> if possible can you give me a hint to start from. Thanks B.R.

57. How to make list of foreign keys (intermediate SQL question)    coderanch.com

I need to create a table of subscribers to a service. At sign-up, the subscriber will choose a number of schools whose sports teams interest him or her. As there may be 1 or more, I need an SQL table construct to simulate what would be an Array or List of indeterminate length in Java or C. I'm just inexperienced enough ...

58. java sql TYPE    coderanch.com

59. Jdbc: Using SQL ARRAY Type    coderanch.com

60. SQL not working    coderanch.com

My sql queries don't seem to be working on my war file running on server. It seems to work locally, but isn't inserting correctly into server, but it seemed to work first time. Is there anyway I can view a command prompt so I can view all the System.out.println()'s. But now that I've said that, I guess I could write these ...

61. No access to SQL Express 2005/2008 database    coderanch.com

I want to link a SQL Server Expess 2005 Database to a simple Java application. The resulting error is: Exception: Fehler bei der Anmeldung fr den Benutzer 'terencewin'. Der Benutzer ist keiner vertrauenswrdigen SQL Server-Verbindung zugeordnet. (means: The user is not associated with a trusted SQL Server connection) Microsoft reccommends: Change the Authentication Mode of the SQL server from "Windows Authentication ...

62. Which version of SQL to install?    coderanch.com

Hi, I want to develop a java based web application in my system and planning to use MS SQL 2008 as back end(to be installed on the same system). But I am not sure which edition of MS SQL to use, can anybody tell me do I need to install "developer edition" or "express edition" or "standard edition" or other? I ...

63. count SQL    coderanch.com

I have a table Cutomer(name, id, phone) and Student(name, department). Assuming "name" is a unique valued column, do you think both of the following two queries generate the "number of customers whose name are in Student table" ? 1. select count(distinct customer.name) from customer, student where customer.name = student.name 2. select count(*) from customer, student where customer.name = student.name

64. SQL databases    coderanch.com

Hi, I'm interested to know about performance in sql tables. I have a table, with 2 bigint columns, and a query of the form "select col2 from table where col1=someValue". There will be 1 row satisfying the query, or no rows at all. I currently have 6,800,000 rows of data spread evenly over 10 tables containing 680,000 rows each. The time ...

65. sql execution problem    coderanch.com

hi friends,wrote some sql code 2 create a table and insert some data into the table.when i executed the command in netbeans 5.5,it executed,created the table and wn i viewed the data in the tabe,it showed the table with the data.but when i used netbeans 6.5,the same sql command executes,but does not show the table or any data,it show SELECT FROM*tablename.throwing ...

66. help locating java.sql    coderanch.com

The problem is that I am developing for BlackBerry and stupid me didn't think it was a compact framework like .net I just have to find a way for the blackberry to query the database from the phone and since the rim package only allows an SD card, i guess I have to use web services. Thanks for the help all, ...

67. SQL formatting question    coderanch.com

When running a program it executes the sql code as follows (the database is there, connected, etc., so the problem is with format): Database fields are named the same as the entries I will be putting into them. The parameters have values other than the parameter name, of course. Prior to this code, the field values are populated into the parameters ...

68. In depth SQL question    coderanch.com

Hi All: I am currently using Ibm Db2 8.2 for mainframe. Is it possible to combine statement1 and statement2 similar to statement 3. Basically I want to use the sql result in statement 1 for product_code and currency_code and placed it in a where clause for statement 2 STATEMENT 1: SELECT DISTINCT PRODUCT_CODE,CURRENCY_CODE FROM TABLE1; STATEMENT 2: SELECT * FROM ACCOUNT ...

69. How to create SQL server2005 database on remote machine using jdbc?    coderanch.com

public class Test { // JDBC driver name and database URL static final String JDBC_DRIVER = "net.sourceforge.jtds.jdbc.Driver"; static final String DB_URL = "jdbc:jtds:sqlserver://10.96.11.31:1433;useNTLMv2=true;domain=myDomain"; public static void main(String[] args) { Connection conn = null; Statement stmt = null; try{ //STEP 2: Register JDBC driver Class.forName(JDBC_DRIVER); //STEP 3: Open a connection System.out.println("Connecting to database..."); conn = DriverManager.getConnection(DB_URL); //STEP 4: Execute a query System.out.println("Creating ...

70. how to pass array value in sql    coderanch.com

I only have time for a quick comment, but I think you're missing some commas between each of the "IN" values, and you have too many right parentheses. Your code looks like it would produce: "...not in (nvl('1001','1'))nvl('1002','1')) [etc...])" You need something like: ...not in (nvl('1001','1'),nvl('1002','1'), [etc...])" Also, if you know you have values in your array, why use NVL() at ...

71. java.sql.SQLIntegrityConstraintViolationException: ORA-02291: integrity constraint    coderanch.com

I got the problem when i try to insert the record in database using servlet the code is //Code to connect to DB try { conn = Connection_database.getConnection(); stmt = conn.createStatement(); stmt1 = conn.createStatement(); pstmt = conn.prepareStatement("insert into emp11 (EMP_ID,Firstname,lastname,gendar,age,address,DEPT_ID) values(?,?,?,?,?,?,?)"); } catch (Exception ex) { ex.printStackTrace(); } } int sn = 1; //Get Data from the form to insert in ...

72. SQL quotation question    coderanch.com

73. SQL from Windows to Ubuntu    coderanch.com

74. IBM DB/2 9.7 ignoring bad SQL in prepareStatement()?    coderanch.com

// need to get a new sequence number batch from d/b PreparedStatement ps = connection.prepareStatement("select " + sequenceName + ".nextval from sys.dual"); try { ResultSet rs = ps.executeQuery(); if (rs.next()) { latestId.setValue(rs.getInt(1)); logger.debug("set sequence " + sequenceName + " via jdbc lookup to " + latestId.intValue()); } else { throw new SQLException("expected result set from " + sequenceName + ".nextval"); } ...

75. Book suggestions for learning SQL database programming?    coderanch.com

Hi guys. I am currently pretty well versed in Java programming, but lack all experience with databases. I am now about to start working on an application for managing a database using SQL commands, nothing too fancy just general usage, and coded in Java ofcourse. I was wondering if you guys have any book recommendations for getting some beginner insight into ...

76. Storing sql null values as "0"    coderanch.com

I am having a problem with the result of a query. My query is resultin in 3 column . Then I add the row toa an arraylist. Sometimes my result will be null, the 3 colums will return nothing, because there is not information available. How can I store those values as '0s' in my arrayList. Thank you in advance This ...

77. Product like Quest's SQL Impact    coderanch.com

79. JDBC / SQL redundancy    dbforums.com

80. JDBC -- using the SUM() built-in SQL function    dbforums.com

Hello, Here's the code, String sql = "SELECT sum(max(seq_sequence_num) + 1) FROM seq_tbl"; res = query.executeQuery(sql); while(res.next()) { System.out.println("2"); seq_number = res.getInt("seq_sequence_num"); System.out.println("Seq Number : " + seq_number); } In the "while" loop, it gives me an error saying "seq_sequence_num" column in invalid. "S0022: Invalid column name 'seq_sequence_num'." That column exists in the "seq_tbl" table, but still i get this error. ...

81. Help with SQL    java-forums.org

82. about sql    java-forums.org

83. sql connectivity    java-forums.org

84. problem in sql connectivity    java-forums.org

public void ToDatabase(){ //Retrieve info from the textfields in the dialog String Name=Name1.getText(); String SName=DomainName.getText(); String Address=IPAddress.getText(); String dbuser=""; String dbpasswd=""; String DriverPrefix="jdbc:odbc"; String DataSource="UserInfo"; //The SQL String String SQLString="INSERT INTO Users(username,domainname,ipaddress)VALUES('"+Name +'",'"+SName+"','"+Address+'")"; //Loads JDBC/ODBC driver try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(Exception e){ JOptionPane.showMessageDialog(null,""+e.getMessage (),"JDBC Driver Error ",JOptionPane.WARNING_MESSAGE); return; } Statement stmt=null; Connection con=null; //Creates connection to the database try{ con=DriverManager.getConnection(DriverPrefix+DataS ource,dbuser,dbpasswd); stmt=con.createStatement(); ...

85. sql editor    java-forums.org

86. problem with jdbc (sql 2000)    java-forums.org

private void add_dr_btActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String p1=License_add_dr_txt.getText(); String p2=pName_add_dr_txt.getText(); String p3=lName_add_dr_txt.getText(); String p4=speci_add_dr_txt.getText(); String p5=date_add_dr_txt.getText(); if (checkFieldsCorrectness(true)) if (Doctor.insertDoctor(p1, p2, p3, p4, p5)==false) JOptionPane.showMessageDialog(this, "Record with the same LicenseNum (" + p1 + ") already exists."); else JOptionPane.showMessageDialog(this, " LicenseNum (" + p1 + ") was added succesfully."); }

87. Design question: where to put sql    java-forums.org

I am making a webapp that displays stats from a database. I am leveraging the SLQ server to aggregate the data, for example to sum over months. This means that i have multiline sql statements in the data access layer of my application. My question is, would it be nicer (better, more easily maintenable) to put the sql statements somewhere in ...

88. SQL friend_id    java-forums.org

hi i have a system where i can add and accept friends which insert into my database into 2 tables friend_Requests and friends. friend requests has 3 columns friend id Primary Key, requester Foreign_Key to username, and recipient Foreign Key to username. As does friends slightly different, friend_id INT REFERENCES friend_Requests, requester foreign key (username), and recipient foreign key (username) I ...

89. SQL management - prepareStatement fails unexpectedly    java-forums.org

[SOLVED] Hi, I'm new here so pleased to meet you all. I'm working on a project management software Java based called Activity Manager V0.3. I'm trying to make it evolve from its primary basis to a real projet management system for my company. In the original software you can basically create tasks, or subtasks attached to a task, subsubtasks... (and so ...

91. Getting primary key information in Pervasive SQL    java-forums.org

I am doing a project in which I have to get the primary key information of a Table at run time. I have to do this task in both SQL Server and Pervasive SQL Databases. I found a function getPrimaryKeys() to do this task. The problem is that this function is giving results in the SQL Server Database but its not ...

92. Getting primary key information from Pervasive SQL    java-forums.org

I am doing a project in which I have to get the primary key information of a Table at run time. I have to do this task in both SQL Server and Pervasive SQL Databases. I found a function getPrimaryKeys() to do this task. The problem is that this function is giving results in the SQL Server Database but its not ...

94. help with sql jdbc    forums.oracle.com

i have small jdbc sql program...first i had one table call clients(client id, firstname, surname) but now i have created another table which is called products(product id, clientid, product) please note the keys clientid(primary key) in clients clientid(foreign key) in products productid(primary key) in products also productid in products table is auto increment number clientid in clients table is auto increment ...