java - JDBC and Database Integration Error -
i have been trying alter information of database different, example in database code there 50 bits of information going in states values , when run jdbc code return how many rows of information there is, works , returns 50 rows. want lower number 50 30, error occurs , don't know how without error occurring. basic cannot find out how it, without error occurring. appreciated, sorry if hard understand asking for, best way can explain it
i had cut alot of rest of code because looks extremely messy on this. here bit of database code having trouble with:
set database sql types false set database sql tdc delete true set database sql tdc update true set database sql translate tti types true set database sql concat nulls true set database sql nulls first true set database sql unique nulls true set database sql convert truncate true set database sql avg scale 0 set database sql double nan true set database sql longvar lob false set database transaction control locks set database default isolation level read committed set database transaction rollback on conflict true set database text table defaults '' set files write delay 20 set files backup increment false set files cache size 10000 set files cache rows 50000 set files scale 1 set files lob scale 32 set files defrag 0 set files nio true set files nio size 256 set files log true set files log size 200 create user sa password "" create schema public authorization dba set schema public create memory table public.explorers(explorerid integer generated default identity(start 0) not null primary key,firstname varchar(50),lastname varchar(50),dob date,email varchar(100),address varchar(100),city varchar(50),state varchar(2),zipcode varchar(10),username varchar(15),password varchar(10),tours varchar(29),bio varchar(4096)) alter table public.explorers alter column explorerid restart 4 create memory table public.states(stateid varchar(2) not null primary key,statename varchar(29) alter sequence system_lobs.lob_id restart 1 set database default initial schema public grant usage on domain information_schema.yes_or_no public grant usage on domain information_schema.time_stamp public grant usage on domain information_schema.cardinal_number public grant usage on domain information_schema.character_data public grant usage on domain information_schema.sql_identifier public grant dba sa set schema public insert states values('ak','alaska') insert states values('al','alabama') insert states values('ar','arkansas') insert states values('az','arizona') insert states values('ca','california') insert states values('co','colorado') insert states values('ct','connecticut') insert states values('dc','district of columbia') insert states values('de','delaware') insert states values('fl','florida') insert states values('ga','georgia') insert states values('hi','hawaii') insert states values('ia','iowa') insert states values('id','idaho') insert states values('il','illinois') insert states values('in','indiana') insert states values('ka','kansas') insert states values('ky','kentucky') insert states values('la','louisiana') insert states values('ma','massachusetts') insert states values('md','maryland') insert states values('me','maine') insert states values('mi','michigan') insert states values('mn','minnesota') insert states values('mo','missouri') insert states values('mt','montana') insert states values('nc','north carolina') insert states values('nd','north dakota') insert states values('ne','nebraska') insert states values('nh','new hampshire') insert states values('nj','new jersey') insert states values('nm','new mexico') insert states values('nv','nevada') insert states values('ny','new york') insert states values('oh','ohio') insert states values('ok','oklahoma') insert states values('or','oregon') insert states values('pa','pennsylvania') insert states values('ri','rhode island') insert states values('sc','south carolina') insert states values('sd','south dakota') insert states values('tn','tennessee') insert states values('tx','texas') insert states values('ut','utah') insert states values('va','virginia') insert states values('vt','vermont') insert states values('wa','washington') insert states values('wi','wisconsin') insert states values('wv','west virginia') insert states values('wy','wyoming')
then here java integration code:
package java.jdbc.beginners; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; public class main { public static void main(string[] args) throws sqlexception { try ( connection conn = dbutil.getconnection(dbtype.hsqldb); statement stmt = conn.createstatement(resultset.type_scroll_insensitive, resultset.concur_read_only); resultset rs = stmt.executequery("select stateid, statename states"); ) { rs.last(); system.out.print("number of rows: " + rs.getrow()); // system.out.println("connected!"); } catch (sqlexception e) { dbutil.processexception(e); } } } package java.jdbc.beginners; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; public class dbutil { private static final string username = "dbuser"; private static final string password = "mypassword"; private static final string h_conn_string = "jdbc:hsqldb:data/explorecalifornia"; private static final string m_conn_string = "jdbc:mysql://localhost/explorecalifornia"; public static connection getconnection(dbtype dbtype) throws sqlexception { switch (dbtype) { case mysql: return drivermanager.getconnection(m_conn_string, username, password); case hsqldb: return drivermanager.getconnection(h_conn_string, username, password); default: return null; } } public static void processexception(sqlexception e) { system.err.println("error message: " + e.getmessage()); system.err.println("error code: " + e.geterrorcode() ); system.err.println("sql state: " + e.getsqlstate()); } }
the error giving me is:
2015-07-17t00:29:59.004+0100 severe readexistingdata failed org.hsqldb.hsqlexception: error in script file: @ org.hsqldb.error.error.error(unknown source) @ org.hsqldb.error.error.error(unknown source) @ org.hsqldb.scriptio.scriptreadertext.readexistingdata(unknown source) @ org.hsqldb.scriptio.scriptreaderbase.readall(unknown source) @ org.hsqldb.persist.log.processscript(unknown source) @ org.hsqldb.persist.log.open(unknown source) @ org.hsqldb.persist.logger.openpersistence(unknown source) @ org.hsqldb.database.reopen(unknown source) @ org.hsqldb.database.open(unknown source) @ org.hsqldb.databasemanager.getdatabase(unknown source) @ org.hsqldb.databasemanager.newsession(unknown source) @ org.hsqldb.jdbc.jdbcconnection.<init>(unknown source) @ org.hsqldb.jdbc.jdbcdriver.getconnection(unknown source) @ org.hsqldb.jdbc.jdbcdriver.connect(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ java.jdbc.beginners.dbutil.getconnection(dbutil.java:23) @ java.jdbc.beginners.main.main(main.java:14) 2015-07-17t00:29:59.011+0100 warning script processing failure org.hsqldb.hsqlexception: error in script file line: 113 org.hsqldb.hsqlexception: error in script file: @ org.hsqldb.error.error.error(unknown source) @ org.hsqldb.scriptio.scriptreadertext.readexistingdata(unknown source) @ org.hsqldb.scriptio.scriptreaderbase.readall(unknown source) @ org.hsqldb.persist.log.processscript(unknown source) @ org.hsqldb.persist.log.open(unknown source) @ org.hsqldb.persist.logger.openpersistence(unknown source) @ org.hsqldb.database.reopen(unknown source) @ org.hsqldb.database.open(unknown source) @ org.hsqldb.databasemanager.getdatabase(unknown source) @ org.hsqldb.databasemanager.newsession(unknown source) @ org.hsqldb.jdbc.jdbcconnection.<init>(unknown source) @ org.hsqldb.jdbc.jdbcdriver.getconnection(unknown source) @ org.hsqldb.jdbc.jdbcdriver.connect(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ java.jdbc.beginners.dbutil.getconnection(dbutil.java:23) @ java.jdbc.beginners.main.main(main.java:14) caused by: org.hsqldb.hsqlexception: error in script file: @ org.hsqldb.error.error.error(unknown source) ... 17 more 2015-07-17t00:29:59.126+0100 severe not reopen database org.hsqldb.hsqlexception: error in script file line: 113 org.hsqldb.hsqlexception: error in script file: @ org.hsqldb.error.error.error(unknown source) @ org.hsqldb.scriptio.scriptreadertext.readexistingdata(unknown source) @ org.hsqldb.scriptio.scriptreaderbase.readall(unknown source) @ org.hsqldb.persist.log.processscript(unknown source) @ org.hsqldb.persist.log.open(unknown source) @ org.hsqldb.persist.logger.openpersistence(unknown source) @ org.hsqldb.database.reopen(unknown source) @ org.hsqldb.database.open(unknown source) @ org.hsqldb.databasemanager.getdatabase(unknown source) @ org.hsqldb.databasemanager.newsession(unknown source) @ org.hsqldb.jdbc.jdbcconnection.<init>(unknown source) @ org.hsqldb.jdbc.jdbcdriver.getconnection(unknown source) @ org.hsqldb.jdbc.jdbcdriver.connect(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ java.jdbc.beginners.dbutil.getconnection(dbutil.java:23) @ java.jdbc.beginners.main.main(main.java:14) caused by: org.hsqldb.hsqlexception: error in script file: @ org.hsqldb.error.error.error(unknown source) ... 17 more error message: error in script file line: 113 org.hsqldb.hsqlexception: error in script file: error code: -25 sql state: s1000
if confusing please let me know , try , explain better!
what mean "limit 50 30", if want 30 states returned, change query here
resultset rs = stmt.executequery("select stateid, statename states limit 30");
also post error mentioned you're getting
Comments
Post a Comment