B4J Question can't connect the right database.

liulifeng77

Active Member
Licensed User
Longtime User
I copy a project (A to B)
In project B ,I set the connectionpool(just changed the database name, both of two are in the same instance named "sqlexpress") :

in project A:
pool.Initialize("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://localhost:1433;Instance Name=SQLEXPRESS;database=liusql","sa","XXXXX")


in project B
pool.Initialize("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://localhost:1433;Instance Name=SQLEXPRESS;database=food","sa","XXXXX")

Now,the question is coming:
I can't connect the table in food(database),



whatever I changed the database name, It always connect the liusql.

so weird?

error information:
psb


database list:

psb
 
Last edited:

liulifeng77

Active Member
Licensed User
Longtime User
涓夋湀 23, 2016 11:03:14 涓嬪崍 com.mchange.v2.log.MLog <clinit>
淇℃伅: MLog clients using java 1.4+ standard logging.
涓夋湀 23, 2016 11:03:14 涓嬪崍 com.mchange.v2.c3p0.C3P0Registry banner
淇℃伅: Initializing c3p0-0.9.2.1 [built 20-March-2013 11:16:28 +0000; debug? true; trace: 10]
涓夋湀 23, 2016 11:03:14 涓嬪崍 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
淇℃伅: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge1et9f19i5shhu2o540|1376c05c, debugUnreturnedConnectionStackTraces -> false, description ->...

anywheresoftware.b4j.objects.SQL@64616ca2
2016-03-23 23:03:15.182:INFO::main: Logging initialized @839ms
2016-03-23 23:03:15.246:INFO:eek:ejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-03-23 23:03:15.295:INFO:eek:ejsh.ContextHandler:main: Started
o.e.j.s.ServletContextHandler@7276c8cd
2016-03-23 23:03:15.297:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened E:\b4j\study_app\Objects\logs\b4j-2016_03_23.request.log
2016-03-23 23:03:15.352:INFO:eek:ejs.ServerConnector:main: Started
ServerConnector@2df32bf7{HTTP/1.1,[http/1.1]}{0.0.0.0:51041}
2016-03-23 23:03:15.353:INFO:eek:ejs.Server:main: Started @1009ms

anywheresoftware.b4j.objects.SQL@2683eba3
Connected
(SQLException) java.sql.SQLException: 对象名 'diancai' 无效。
 

Attachments

  • 12.PNG
    12.PNG
    30.2 KB · Views: 202
Upvote 0

fixit30

Active Member
Licensed User
Longtime User
The error is in your SQL Statement or Database Structure.

Error: Object name ' diancai ' is invalid.
 
Upvote 0

liulifeng77

Active Member
Licensed User
Longtime User
I tried dbo.diancai. it shows the same error.
I tried change JDBC url database-->databasename, it shows a new error!
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
What's the new error (logs)? Which code cause the error ? More information or we will just guess.

Try
Copy the tables into the old database and test
Or use MS JDBC driver instead

edit
Find any differences between the two database, owner,permission...
 
Last edited:
Upvote 0

liulifeng77

Active Member
Licensed User
Longtime User
change JDBC url database-->databasename, it shows a new error!
涓夋湀 24, 2016 9:36:10 涓嬪崍 com.mchange.v2.log.MLog <clinit>
淇℃伅: MLog clients using java 1.4+ standard logging.
涓夋湀 24, 2016 9:36:10 涓嬪崍 com.mchange.v2.c3p0.C3P0Registry banner
淇℃伅: Initializing c3p0-0.9.2.1 [built 20-March-2013 11:16:28 +0000; debug? true; trace: 10]
涓夋湀 24, 2016 9:36:11 涓嬪崍 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
淇℃伅: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge1et9f1auhoh211xrbxq|1376c05c, debugUnreturnedConnectionStackTraces -> false, description -...
about._buildpage (java line: 68)
java.sql.SQLException: 瀵硅薄鍚?'main' 鏃犳晥銆?
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:671)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:505)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:1029)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:116)
at anywheresoftware.b4j.objects.SQL.ExecQuery2(SQL.java:290)
at anywheresoftware.b4j.objects.SQL.ExecQuery(SQL.java:271)
at b4j.food.about._buildpage(about.java:68)
at b4j.food.about._initialize(about.java:182)
at b4j.food.main._appstart(main.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.food.main.main(main.java:29)
 

Attachments

  • 1.PNG
    1.PNG
    27 KB · Views: 203
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
Some parts of log are not readable.

Maybe it's more practical to :
Find any differences between the two databases, owner ,permission...
Or just make a clone of previous(working) database, and copy the tables into it.
 
Upvote 0

liulifeng77

Active Member
Licensed User
Longtime User
No matter what the database name changed, It seems always connected the old database(liusql).
 
Last edited:
Upvote 0
Top