I am trying to use JPA with SQL Server. Eclipse has great tools to map entities from database and vice-versa. For this to work, I need to associate a connection to a JPA project.
So I created a database (named it "rowcount") and a table on this database. Then when I go to Eclipse, open the JPA perspective, log in the database (Datasource Explorer / Database Connections), I cannot see any Schema associated to this particular database.
Looking in the "Error Log" view of Eclipse, I've got the following error everytime I click on "Schemas" tree-view item on Eclipse:
eclipse.buildId=M20130204-1200
java.version=1.7.0_15
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=pt_BR
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
Error
Tue May 21 10:34:42 BRT 2013
com.microsoft.sqlserver.jdbc.SQLServerException
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'rowcount'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:792)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:689)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:616)
at org.eclipse.datatools.connectivity.sqm.internal.core.connection.StatementAdapter.executeQuery(StatementAdapter.java:73)
at org.eclipse.datatools.enablement.msft.internal.sqlserver.loaders.SQL2005SchemaLoader.createResultSet(SQL2005SchemaLoader.java:53)
at org.eclipse.datatools.connectivity.sqm.loader.JDBCSchemaLoader.loadSchemas(JDBCSchemaLoader.java:111)
at org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCCatalog.loadSchemas(JDBCCatalog.java:101)
at org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCCatalog.getSchemas(JDBCCatalog.java:64)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.vnode.ServerExplorerVNodeContentProviderNav.displaySchemaNodeChildren(ServerExplorerVNodeContentProviderNav.java:126)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractOnDemandContentProviderNav.getChildren(AbstractOnDemandContentProviderNav.java:169)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractOnDemandContentProviderNav.getChildren(AbstractOnDemandContentProviderNav.java:243)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractLayoutProviderNav.getChildren(AbstractLayoutProviderNav.java:85)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.impl.ServerExplorerContentProviderNav.load(ServerExplorerContentProviderNav.java:153)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.loading.LoadingJob.run(LoadingJob.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
I am using the latest sqljdbc4.jar and "Microsoft SQL Server 2008 JDBC Driver" in the JPA Driver properties.
This error prevents me to deploy the application in an EAR file. Even if I manage to deploy it manually on Weblogic, the application fails for the following reason:
openjpa-1.1.1-SNAPSHOT-r422266:957329 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "SELECT N FROM Note N". Error message: The name "Note" is not a recognized entity or identifier. Known entity names: []
Oddly, "master" database shows some of its objects and schemas. Is there a workaround in SQL Server, in the JDBC driver or Eclipse for this?
Shame on me. The problem was caused because the database name was a reserved word for SQL Server. After I renamed it, it worked fine.
See the comments above, on the question.
My sincere apologies to all who stumbled here while being stressed by real problems.
Related
I'm creating a Spring Boot application and I'm using Intellij's embedded h2 database.
I have added the following lines in my application.properties file:
spring.datasource.url=jdbc:h2:~/testdb;MV_STORE=false;AUTO_SERVER=TRUE
This is my data source configuration
Although the connection is successful and I can query the database using Intellij's query console, the tables do not appear in the Database tab.
Succeeded
DBMS: H2 (ver. 2.1.210 (2022-01-17))
Case sensitivity: plain=upper, delimited=exact
Driver: H2 JDBC Driver (ver. 2.1.210 (2022-01-17), JDBC4.2)
Ping: 16 ms
When I refresh the connection or go to the schemas tab of the data source configuration, I get the following error:
[42S02][42102] org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "INFORMATION_SCHEMA_CATALOG_NAME" not found; SQL statement: select CATALOG_NAME from INFORMATION_SCHEMA.INFORMATION_SCHEMA_CATALOG_NAME [42102-210].
By going to the advanced tab of the data source and clicking on expert options, we are presented with a checkbox labeled "Introspect using JDBC metadata"
By checking that box, the tables successfully appear in the Database tab
Regarding why this works, this is taken from the official documentation:
https://www.jetbrains.com/help/datagrip/data-sources-and-drivers-dialog.html
Introspect using JDBC metadata
Switch to the JDBC-based introspector. Available for all the databases.
To retrieve information about database objects (DB metadata), DataGrip uses the following introspectors:
A native introspector (might be unavailable for certain DBMS). The native introspector uses DBMS-specific tables and views as a source of metadata. It can retrieve DBMS-specific details and produce a more precise picture of database objects.
A JDBC-based introspector (available for all the DBMS). The JDBC-based introspector uses the metadata provided by the JDBC driver. It can retrieve only standard information about database objects and their properties.
Consider using the JDBC-based intorspector when the native introspector fails or is not available.
The native introspector can fail, when your database server version is older than the minimum version supported by DataGrip.
You can try to switch to the JDBC-based introspector to fix problems with retrieving the database structure information from your database. For example, when the schemas that exist in your database or database objects below the schema level are not shown in the Database tool window.
I am trying to create a view which should select data from snapshot database table on SQL Server 2017.
However I become the following error:
An error occurred in the Microsoft . NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted.
The problem is with one assembly, but in case of other views everything works fine. Any suggestions what needs to be done?
I need to update the compatibility level of the Azure SSAS Model to 1400. It's currently in 1200. When I click on Model.bim and go to Properties. (Inside Visual Studio 2017) There is no option to select from under the property "Compatibility Level".
I am currently on VS 2017 (Version 15.9.9)
The .NET Framework is on (Version 4.7.03062)
I did follow this article but still don't see the options to change it.
https://azure.microsoft.com/en-au/blog/1400-models-in-azure-as/
My solution is also in Source Control.
There is actually a bug in the server properties for SSAS in SSMS (at least as of SSMS 17.x). It probably applies to your case too.
The actual compatibility mode that is used by your model is set in the model itself.
The server has 2 properties:
DefaultCompatibilityMode - probably used only when Create is executed (without the compatibility)
SupportCompatibilityModes which is a list of supported levels.
Execute the following XMLA window in SSMS (taken from social.msdn):
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>DISCOVER_XML_METADATA</RequestType>
<Restrictions>
<RestrictionList>
<ObjectExpansion>ObjectProperties</ObjectExpansion>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
</PropertyList>
</Properties>
</Discover>
Search for Compatibility. You should be able to see for an SSAS 2017 server:
<ddl400:DefaultCompatibilityLevel>1200</ddl400:DefaultCompatibilityLevel>
<ddl600:SupportedCompatibilityLevels>1100,1103,1200,1400</ddl600:SupportedCompatibilityLevels>
The DefaultCompatibilityLevel should match the requested compatibility level. In your case 1400. You should be able to confirm the mode that the model is running in by checking its properties in SSMS. You can, of course, change only to SupportedCompatibilityLevels. Should your required compatibility level not be listed, you are out of luck.
You can, of course, change only to SupportedCompatibilityLevels.
#tukan Thanks. I changed to 1400 in Visual Studio and I can see 1400 in the server.
<ddl600:SupportedCompatibilityLevels>1100,1103,1200,1400</ddl600:SupportedCompatibilityLevels>
However, when I try to deploy I get the following error:
The JSON DDL request failed with the following error: Failed to execute XMLA. Error returned: 'The operation cannot be performed because it references an object or property that is unavailable in the current edition of the server or the compatibility level of the database.
It feels like the level is 1200 and can't deploy 1400 even that it is supported.
I am having a problem with connecting to data in SQL database.
I am not sure if I don't have the certain driver or if the code I am using is incorrect. Could someone please help guide me in the right direction?
Below is the product license that I have after running Proc Setinit
Operating System: WX64_WKS.
Product expiration dates:
---Base SAS Software
14FEB2018
---SAS/STAT
14FEB2018
---SAS/GRAPH
14FEB2018
---SAS/Secure 168-bit
14FEB2018
---SAS/Secure Windows
14FEB2018
---SAS Enterprise Guide
14FEB2018
---SAS/ACCESS Interface to PC Files
14FEB2018
---SAS/ACCESS Interface to Microsoft SQL Server
31DEC2017
---SAS Workspace Server for Local Access
14FEB2018
---SAS/ACCESS to Amazon Redshift
31DEC2017
---High Performance Suite
14FEB2018
Below is product installed after I ran Proc Product_Status
16 proc Product_Status ; run;
For Base SAS Software ...
Custom version information: 9.4_M5
Image version information: 9.04.01M5P090617
For SAS/STAT ...
Custom version information: 14.3
For SAS/GRAPH ...
Custom version information: 9.4_M5
For SAS/ACCESS to Amazon Redshift ...
Custom version information: 9.42
For High Performance Suite ...
Custom version information: 2.2_M6
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M5
NOTE: PROCEDURE PRODUCT_STATUS used (Total process time):
real time 0.24 seconds
It seems like sas access to SQL server is not installed right?
I am also trying these codes to connect and all got the error. Which direction of code should I be using? ODBC or sqlsvr?
I tried sqlsvr and got this error message
Code:
LIBNAME database1 sqlsvr user=datareader password=myspassword DATAsrc=clientA;
Error:
LIBNAME database1 sqlsvr user=datareader password=XXXXXXX
DATAsrc=clientA;
ERROR: CLI error trying to establish connection: [Microsoft][ODBC
Driver Manager] Data source name not found and no default driver
specified ERROR: Error in the LIBNAME statement.
When I tried ODBC route, I got this message
Code:
LIBNAME database1 ODBC DSN=clientA User=datareader Password=myspassword ;
Error:
LIBNAME database1 ODBC DSN=clientA User=datareader Password=XXXXXXX;
ERROR: The ODBC engine cannot be found. ERROR: Error in the LIBNAME
statement.
Could someone please point me in the right direction? Should DSN be the name of the database of each client as "ClientA" etc or should it be the name of the server?
Thank you so much!
The SQLSRV library engine DATASRC= option should specify an entry shown in the "ODBC Data Source Administrator (64-bit)" application. You can add an entry, set (configure) the connection parameters and test the connection. Suppose you name your new DSN Sales History, the libname might be
libname OldSales sqlsrv datasrc="Sales History" user=... pass=...;
For the case of wanting to specify the server name, schema, port, connection persistence, etcetera directly in your SAS code you would use the NOPROMPT= option. The option value will be a semi-colon separated list of name=value pairs:
libname OldSales sqlsrv user=... pass=... noprompt="Server=<url or hostname><\instance-name-if-other-than-default>,<port-number-if-other-than-default>;Initial Catalog=<database-to-use-if-other-than-default>;..other connection parameters..";
Microsoft documentation "Using Connection String Keywords with SQL Server Native Client" is a great reference. Another good resource for examples is connectionstrings website. A NOPROMPT= value that seems correct, yet is not to working, may have or require unusual spacing or quoting.
For a small group of coders in a static data hosting environment the NOPROMPT= method will probably be OK and require no extra support (other than access) in a large organization. If the data hosting migrates or changes your SAS code will have to be changed.
In a larger context, especially in a SAS Server environment, you are best off having your IT support to create the DSNs that your SAS sessions will need. The DSNs will be the single gateway that all programs and users will use and coders and analysts will not have to get bogged down in the connection details.
I'm getting the exception
The underlying provider failed on ConnectionString.
with inner exception
Invalid value for key 'attachdbfilename'
on a windows 7 home premium virtual machine as i'm trying to deploy and debug my application.
However, on my development machine, the application just launches without problems.
the connection string is :
<add name="AssetsLocalDBEntities" connectionString="metadata=res://*/AssetsLocalDB.csdl|res://*/AssetsLocalDB.ssdl|res://*/AssetsLocalDB.msl;provider=System.Data.SqlClient;provider connection string="data source=(localdb)\v11.0;attachdbfilename=|DataDirectory|\AssetDatabase.mdf;initial catalog=AssetDBSource;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Steve Wellens has mentioned that the connection string contains garbage in this topic:
The underlying provider failed on ConnectionString
yet, as Maxim Gueivandov has replied, this should valid connection string, as it's directly generated by the EntityFramework's edmx designer.
At least, i believe it to be valid, as it does work on the development machine.
Also in another topic (Entity Framework - The underlying provider failed on ConnectionString), the accepted answer is to remove the " and replace them by \", as the string is a literal in the c# code, yet i still have my connection string in xml, so " cannot simply be replaced.
on-connectionstring
The .NET version installed on the virtual machine is 4.0.30319 and MsSQL Server Express LocalDB is 11.0.2318.0, so i believe they are both up to date.
Edit: If i remove "|DataDirectory|" from the connection string i get the following error on my development machine:
Cannot attach the file 'AssetDatabase.mdf' as database 'AssetDBSource'.
So i also remove "initial catalog=AssetDBSource" and i get
An attempt to attach an auto-named database for file AssetDatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
i can emagine this is because it doesn't know where to look? so, i provide it the full path (C:..\AssetDatabase.mdf) and it works.
So the remainder of the question is: how do i get relative paths working with LocalDB?
I believe the target machine doesn't have the Update 4.0.2 or later for .NET 4 installed. The .NET 4 version number can be confusing, as version 4.0.30319 seems to be used by all .NET 4 builds. In effect it does not mean your machine has the Update 4.0.2.
Can you install .NET 4 Update 4.0.3 (latest .NET 4 update as of today) on the target machine and see if the problem goes away?
Or just verify that the update is installed - just build a simple application in .NET 4 that uses SqlClient to connect to LocalDB using the connection string, and record the error information in case you still hit any errors. The EF error message is fairly generic, and I don't know how to get a detailed error from the underlying SqlClient provider.
Alternatively you could also migrate it to .NET 4.5.