Database over the Internet
I got a big problem with some java over the Internet. I wanna make a Applet who can save data in a database, over the internet ( ftp )
Havent tried this kind of database before but what do I need to change in this code belove to make it work?? I guess I need some kind of url, username, and password right??
Plz help me!!!
protected void insertObjectInStorage(OID oid, Object object)
Spillere s = ( Spillere )object;
Connection con = null;
Statement stmt = null;
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
con = DriverManager.getConnection("jdbcdbc:bgladder");
stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO Spillere VALUES ( '" + oid.toString() + "', '"+s.getNavn() + "', '"+ s.getPassword() + "', '"+ s.getWins() + "', '" + s.getLoss() + "', '" + s.getPoints() + "' )");
System.err.println("Der er fejl -->" + ex.getMessage() );
I once had a problem similer to the one you have, so I hope my solution can help you.
You downloaded the JDBC driver, If I'm not mistaking it is a .jar file. Take the java applet and put in in a HTML page. Put that html page on the same server as your database is. Let's put in a folder called html
Now unpack the .jar file (winace of winrar can do the job...on a windows machine that is) when unpacked there should be a org folder. put in also on the server where the database is. Put it in the same place where the html folder is.
This is what worked for me, I hope it also works for you
Ok thx dude, but what about my code?? It have to be modified to be used like that right? like odbc.jdbc:bgladder
it cant see this because its on a server I guess.
What do I change this to ?
Uhm, now this is a difficult question...i missed out on a piece of important information...The JDBC I used is to connect with a PostGre SQL database, if you use a different database language your .jar file may be a bit different, but it probably has the same structure.
To work from my own code, you indeed need to change your code a bit:
Class.forName("org.postgresql.Driver"); //org is the main folder in the .jar file I used. In that is a folder called postgresql and Driver is a .class file
conn = DriverManager.getConnection(url, userName, passWord);
//url is the adress the applet needs to point to i.e.:
The fist four * are the adress where of the server, this might be more or less, depending on the adress. The fifth * is the poort / gate (I don't know the proper English word) and the last is the database name.
If you need a username and password you can also fill it in here. Use strings for the url, username and password.
Ok thx man but what if it is a microsoft access database?
As far as I know you can't just run an Access database on a server. This is what you need to do. You need to export your database into SQL. Change the SQL in the dialect you use and put it on the server (I wish I could help you on this, but I can't. I never did this.) Then make a new empty database in Acces and import the database in Acces...
I'm sorry, but if you need more help on the database, I can't help you...With Java, well...I can give some more support there.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL