• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC can i connect

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,
I am doing a project in which i have an applet running where there are some textfields and i wan to store the data from the applet in the database or in the text file format..
How do i go about it ...can some body throw light on this ..as i have to implement it sooner........
Kajol
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
simple to do list:
1. politytool
2. create an odbc dsn entry to us a text file database
3. use jdbc 1.0 open the driver and insert rows...
hope this helps!
<code>
import java.sql.*; //import all the JDBC classes
public class CreateJoltData {
static String[] SQL = {
"create table JoltData ("+
"programmer varchar (32),"+
"day varchar (3),"+
"cups integer);",
"insert into JoltData values ('Gilbert', 'Mon', 1);",
"insert into JoltData values ('Wally', 'Mon', 2);",
"insert into JoltData values ('Edgar', 'Tue', 8);",
"insert into JoltData values ('Wally', 'Tue', 2);",
"insert into JoltData values ('Eugene', 'Tue', 3);",
"insert into JoltData values ('Josephine', 'Wed', 2);",
"insert into JoltData values ('Eugene', 'Thu', 3);",
"insert into JoltData values ('Gilbert', 'Thu', 1);",
"insert into JoltData values ('Clarence', 'Fri', 9);",
"insert into JoltData values ('Edgar', 'Fri', 3);",
"insert into JoltData values ('Josephine', 'Fri', 4);",
};
// connect via jdbc/odbc to a dir that contains text files
// for each tablename there will be a textfile * scheme.ini file created
public static void main(String[] args) {
String URL = "jdbc:odbc:textDB";
String username = "";
String password = "";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (Exception e) {
System.out.println("Failed to load JDBC/ODBC driver.");
return;
}
Statement stmt = null;
Connection con=null;
try {
con = DriverManager.getConnection (
URL,
username,
password);
stmt = con.createStatement();
} catch (Exception e) {
System.err.println("problems connecting to "+URL);
}
try {
// execute SQL commands to create table, insert data
for (int i=0; i<SQL.length; i++) {>
stmt.execute(SQL[i]);
}
con.close();
} catch (Exception e) {
System.err.println("problems with SQL sent to "+URL+
": "+e.getMessage());
}
}
}
</code>
------------------
Multi-Platform Database Developer ( on E.S.T. )
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Monty Ireland:
simple to do list:
1. politytool
2. create an odbc dsn entry to us a text file database
3. use jdbc 1.0 open the driver and insert rows...
hope this helps!


Monty,
Am I missing something -- what is "politytool"??
Also, I set up a User DNS connection and I ran your code. Once it attempts to execute the SQL, I'm getting an error which says: "Cannot modify the design of table 'JoltData'. It is in a read-only database." Any ideas? The file itself does not have any special permissions on it.
Thanks,
Rebecca

[This message has been edited by Rebecca Pickett (edited April 11, 2001).]
 
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. POLICYTOOL is a java utility used to grant permissions.... security etc...

Please review the java doc and this jdbc form for politytool ussage.... search for POLICYTOOL and/or Monty
2. I just ran my code and it worked fine....
3. I think you need to run POLICYTOOLs.
4. For more information please review JDBC API TUTORIAL... 'IDBC 0-201-43328-1' contains a good applet/jdbc example if you need more information...
------------------
Multi-Platform Database Developer ( on E.S.T. )

[This message has been edited by Monty Ireland (edited April 11, 2001).]
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Monty,
Sorry to say but since i am a beginner for JDBC, if you dont mind can u please explain me the code and i tried to compile your code but it gives me error..
Waitng for your reply..Monty and thanks a lot for ur help...
Kajol
 
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you are new to JDBC... welcome
Since you are new to jdbc... I think you should beg borrow and/or steal the following book:
'JDBC API Tutorial and Reference, 2nd Edition' ISBN 0-201-433-28-1 .... read chapt 2 its about 50 pages... very good tutorial...
good examples...
Before we being... What is you backround...
Mine is:
15 of software development experience...
10 yrs dev database application software..
For 3 yrs I have been teaching myself java...
Last summer i passed the SCJP2 (310-25) exam...
I develope software on MVS UNIX NT
Using DB2 ORACLE Cloudscape
With ASSEMBLER, COBOL, C, PERL, & JAVA....
Presently I have java & other tools installed on NT and win98...
jdk1.3 j2sdkee1.2.1 tomcat3.1 cloudscape3.6
My current assignment has me developing a database application using oracle pro*c pl/sql & c w/ embedded sql. It's a living...
Pls reply w/ you backround...
Feel free to send me an email directly...
I chack java rach posts 3 - 4 times a day...
my emails at home avery day or so...
Monty -- aka monty6 before proper names

------------------
Multi-Platform Database Developer ( on E.S.T. )
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Monty,
Thanks for ur prompt reply.
I went throught ur mail and its very much impressive.
Well i am a beginner and have emailed u in detail about me.
Will wait for ur reply.
Kajol
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,
Please reply to me ..
I need to implement it ..
Thanks a lot in advance..
Kajol
 
reply
    Bookmark Topic Watch Topic
  • New Topic