inserting a record into Access database
Hi guys i am having problem with the insertion of a record in to a Access database!!!!
It is not given any exceptions or errors but simply does not insert it!!!
Here is my code!!
import java.sql.*;
class access
{
public static void main(String a[])
{
// Set default values for the command line args\par
Connection connection;// Connection to the database
Statement statement;// Statement object for queries
String user= "";
String password = "";
String url= "jdbc:odbc:db1";
String driver= "sun.jdbc.odbc.JdbcOdbcDriver";
try
{
Class.forName(driver);// Load the driver
connection = DriverManager.getConnection(url, user, password);
if(a.length !=0)
{
PreparedStatement ps = connection.prepareStatement("insert into search(Orgname,Website) values(?,?)");
ps.setString(1,a[0]);
ps.setString(2,a[1]);
int res = ps.executeUpdate();
System.out.println("i am in" + " the output result no ="+res );
ps.close();
}
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);// Driver not found
}
catch(SQLException sqle)
{
System.err.println(sqle); // error connection to database
}
}
}
-DK
[1337 byte] By [
decaynan] at [2007-9-26 1:59:00]

sounds like if you close the connection, it might commit and that may work?
> from what I've seen in this forum it seems to be a
> fairly common problem. if you call a Select statement
> following the insert, it usually forces the insert to
> mysteriously appear.
>
> good old M$
>
> Jamie
This is kind of out of track, but about mysql, if I use the library, I wonder if that would force me to ship my source code or not. The license said if it's "using" instead of "deriving" then my code is not GNU. However, there is some linking here. For java, it's class file so no source is included, however, in c++ for example, when you include a header file, does that means I already link my code with existing code? Then there is a clause say that if there are 10 lines or less (or something like that) then it's ok. What a mess with this GNU thing. Can some of you clear this up for me, please. Thank you in advance.
Another thing about MySql, I tried it, and it works, however, it's like hackers' tool, at least for the c++ library. They don't have move next or things like that (you increase the iterator instead), it looks real different from API like dao or ado or jdbc. Anyone bother give me some comment?
VH
vy_ho at 2007-6-29 3:17:34 >

I'm not sure, but I think, linking your code against a library is considered as "using", not "deriving", since you don't change the library itself.
It should not matter, whether you link staticly or dynamicly or only ship a file to use it with a program (like reading an image).
Otherwise: how could anyone "use" a static library without linking his code to it?
If - like you described - some features are "too low level" for your taste (I would feel similiar), I can only tell my experience:
With InterBase you have a GPL'd DBMS which is available in fully mainted shape. You can download the executables and use it like a commercial DBMS - no touch with libraries or the sources, if you don't want.
IBConsole is a tool that can be compared with MS SQLServer's Enterprise Manager, I think!
InterClient/InterServer offers a JDBC type 3 driver.
There are also some ODBC drivers for it at the market.
This is real Open Source!
What do you want more?