不要学1.3了,你可以去下这两个版本的api问题定能解决
解决方案 »
- java socket 服务端优化! 求高手
- Spring MVC+FreeMarker 怎样实现动态安装模板?
- liferay 5.2.3 ext开发时,点击deploy之后显示一直等待,就是不成功
- java 怎么实现 大文件上传。 。 。
- jsp怎样把数据提交给另一个servlet处理。在 web.xml里面怎么配的 :
- 命名SQL写法怎样写才对?
- 我的网站类似chinaren。比他功能要多很多,数据也很大,不知用什么服务器比较好?
- 请问哪能弄到有关spring入门的中文资料!
- 如何配置使得weblogic8可以使用jbuilder9的jdatastore,谢谢了
- 微信开发手机摇一摇声效如何设置?
- 请问如何使用jb9.0部署rmi
- web.xml咋就这么难呢?希望高手指点
请问1.4下怎么用啊?import java.sql.*;
public class CreateAgency {
private static final String framework = "embedded";
private static final String driver = "COM.cloudscape.core.JDBCDriver";
private static final String protocol = "jdbc:cloudscape:Agency;create=true";
public static void main(String[] args) {
try {
Class.forName(driver);
System.out.println("Loaded driver: "+driver); Connection conn = DriverManager.getConnection(protocol);
System.out.println("Connected to: "+protocol);
conn.setAutoCommit(false); Statement s = conn.createStatement(); System.out.println("Dropping exisiting tables...");
try {s.execute("drop table ApplicantSkill");} catch (SQLException ex){}
try {s.execute("drop table Applicant");} catch (SQLException ex){}
try {s.execute("drop table JobSkill");} catch (SQLException ex){}
try {s.execute("drop table Job");} catch (SQLException ex){}
try {s.execute("drop table Matched");} catch (SQLException ex){}
try {s.execute("drop table Customer");} catch (SQLException ex){}
try {s.execute("drop table Location");} catch (SQLException ex){}
try {s.execute("drop table Skill");} catch (SQLException ex){}
System.out.println("Dropped tables"); System.out.println("Creating new tables...");
s.execute("create table Skill(name varchar(16), description varchar(64))");
s.execute("create table Location(name varchar(16), description varchar(64))");
s.execute("create table Applicant(login varchar(16), name varchar(64), email varchar(64), summary varchar(512), location varchar(16))");
s.execute("create table ApplicantSkill(applicant varchar(16), skill varchar(16))");
s.execute("create table Customer(login varchar(16), name varchar(64), email varchar(64), address1 varchar(64), address2 varchar(64))");
s.execute("create table Job(ref varchar(16), customer varchar(16), description varchar(512), location varchar(16))");
s.execute("create table JobSkill(job varchar(16), customer varchar(16), skill varchar(16))");
s.execute("create table Matched(applicant varchar(16), job varchar(16), customer varchar(16), exact boolean)");
System.out.println("Created tables"); System.out.println("Inserting table records...");
s.execute("insert into Location values ('London','London UK')");
s.execute("insert into Location values ('Washington','Washington DC, USA')");
s.execute("insert into Location values ('Verona','Verona, Renaissance Italy')");
s.execute("insert into Location values ('Wessex','Wessex, Kingdom of England')"); s.execute("insert into Skill values ('Tree Surgeon','Tree Surgeon')");
s.execute("insert into Skill values ('Cigar Maker','Cigar Maker')");
s.execute("insert into Skill values ('Bodyguard','Bodyguard')");
s.execute("insert into Skill values ('Cook','Cook')");
s.execute("insert into Skill values ('Lawyer','Lawyer')");
s.execute("insert into Skill values ('Critic','Critic')"); s.execute("insert into Applicant values ('juliet','Juliet Capulet', '[email protected]' , 'Dutiful daughter', 'London' )");
s.execute("insert into Applicant values ('romeo','Romeo Montague', '[email protected]' , 'Dutiful son', 'Wessex' )");
s.execute("insert into Applicant values ('julius','Julius Caesar', '[email protected]' , 'Roman Emperor', 'Washington' )");
s.execute("insert into Applicant values ('brutus','Marcus Brutus', '[email protected]' , 'Roman Senator', 'Washington' )");
s.execute("insert into Applicant values ('proteus','Proteus', '[email protected]' , 'Gentleman', 'Verona' )");
s.execute("insert into Applicant values ('valentine','Valentine', '[email protected]' , 'Gentleman', 'Verona' )"); s.execute("insert into ApplicantSkill values ('juliet', 'Cook')");
s.execute("insert into ApplicantSkill values ('romeo', 'Cook')");
s.execute("insert into ApplicantSkill values ('romeo', 'Bodyguard')");
s.execute("insert into ApplicantSkill values ('julius', 'Tree Surgeon' )");
s.execute("insert into ApplicantSkill values ('julius', 'Tree Surgeon' )");
s.execute("insert into ApplicantSkill values ('brutus', 'Critic' )");
s.execute("insert into ApplicantSkill values ('brutus', 'Lawyer' )");
s.execute("insert into ApplicantSkill values ('proteus', 'Lawyer' )");
s.execute("insert into ApplicantSkill values ('proteus', 'Critic' )");
s.execute("insert into ApplicantSkill values ('valentine', 'Critic' )");
s.execute("insert into ApplicantSkill values ('valentine', 'Cigar Maker' )"); s.execute("insert into Customer values ('george','George Washington', '[email protected]', 'White House', 'Washington')");
s.execute("insert into Customer values ('winston','Winston S Churchill', '[email protected]', '10 Downing Street', 'London')");
s.execute("insert into Customer values ('abraham','Abraham Lincoln', '[email protected]', 'Springfield', 'Illinois')");
s.execute("insert into Customer values ('alfred','Alfred the Great', '[email protected]', 'Wessex', 'England')"); s.execute("insert into Job values ('Tree pruner', 'george', 'Must be honest', 'Washington')");
s.execute("insert into Job values ('Cigar trimmer', 'winston', 'Must like to talk and smoke', 'London')");
s.execute("insert into Job values ('Theatre goer', 'abraham', 'Should be intelligent and articulate', 'Washington')");
s.execute("insert into Job values ('Cake maker', 'alfred', 'Should have a good sense of smell', 'Wessex')"); s.execute("insert into JobSkill values ('Tree pruner','george','Tree Surgeon')");
s.execute("insert into JobSkill values ('Cigar trimmer', 'winston', 'Cigar Maker')");
s.execute("insert into JobSkill values ('Cigar trimmer', 'winston', 'Critic')");
s.execute("insert into JobSkill values ('Theatre goer', 'abraham', 'Bodyguard')");
s.execute("insert into JobSkill values ('Theatre goer', 'abraham', 'Lawyer')");
s.execute("insert into JobSkill values ('Theatre goer', 'abraham', 'Critic')");
s.execute("insert into JobSkill values ('Cake maker', 'alfred', 'Cook')"); System.out.println("Inserted records"); conn.commit();
s.close();
conn.close();
System.out.println("Committed transaction and closed connection");
}
catch (SQLException ex) {
System.out.println("SQL Exception thrown: "+ex);
ex.printStackTrace();
}
catch (ClassNotFoundException ex) {
System.out.println(ex);
ex.printStackTrace();
}
// shutdown cloudscape
// this always throws an exception try {
DriverManager.getConnection("jdbc:cloudscape:;shutdown=true");
System.out.println("Database did not shut down normally");
}
catch (SQLException ex) {
System.out.println("Database shut down normally");
}
}
}
主要是在Class.forName(driver);
Connection conn = DriverManager.getConnection(protocol);
这两句话就要具体问题具体对待,如不同的数据库等