My springboot project has correctly configured JDBC of TDengine:
datasource:
dynamic:
druid:
max-active: 20
initial-size: 4
min-idle: 4
max-wait: 60000
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
test-while-idle: false
test-on-borrow: false
test-on-return: false
filters: stat
primary: td-engine
strict: false
datasource:
td-engine:
driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
url: jdbc:TAOS-RS://192.168.1.161:6041/taoskeeper?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
username: ****
password: ****
When I execute on a existed table: table1:
select * from table1
{\"status\":\"error\",\"code\":535,\"desc\":\"Database not specified or available\"}
I got the result of not specified or available error, even I execute "use mydatabase" first.
The JDBC restful api is stateless, which means database has to be selected in sql, the correct sql statement should be :
select * from mydatabase.table1
Related
I've been working with dbt for a couple of months now, so still fairly new to it. When running a test model, I have no problems when using the view materialization:
{{ config(materialized='view') }}
select 1 as id
Resulting in:
15:30:25 | 1 of 1 START view model dbt.stg_CampaignTableTest.................... [RUN]
15:30:26 | 1 of 1 OK created view model dbt.stg_CampaignTableTest............... [SUCCESS 1 in 1.48s]
However, when I make the switch to a table materialization I get an error message about not having an active warehouse selected in Snowflake:
{{ config(materialized='table') }}
select 1 as id
Resulting in:
15:32:52 | 1 of 1 START table model dbt.stg_CampaignTableTest................... [RUN]
15:32:53 | 1 of 1 ERROR creating table model dbt.stg_CampaignTableTest.......... [ERROR in 1.22s]
Database Error in model stg_CampaignTableTest (models/test/stg_CampaignTableTest.sql)
000606 (57P03): No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command.
Of course, it's not possible to include a "use warehouse" statement within my test model as it is inserted into the compiled SQL at the wrong position:
{{ config(materialized='table') }}
use warehouse "AnalysisTeam_WH";
select 1 as id
Because it leads to:
2021-10-07T15:33:59.366279Z: On model.my_new_project.stg_CampaignTableTest: /* {"app": "dbt", "dbt_version": "0.21.0", "profile_name": "user", "target_name": "default", "node_id": "model.my_new_project.stg_CampaignTableTest"} */
create or replace transient table "AnalysisTeam"."dbt"."stg_CampaignTableTest" as
(
use warehouse "AnalysisTeam_WH";
2021-10-07T15:33:59.366342Z: Opening a new connection, currently in state closed
2021-10-07T15:34:00.163673Z: Snowflake query id: 019f7386-3200-ec67-0000-464100e189fa
2021-10-07T15:34:00.163803Z: Snowflake error: 001003 (42000): SQL compilation error:
syntax error line 4 at position 0 unexpected 'use'.
I appear to have the correct permissions with my Snowflake 'role' to create tables, views, etc., so I was at a loss to understand why changing from view to table would cause the model to fail. I suspect it could be related to Snowflake permissions rather than a dbt issue but I am not sure. Any ideas would be really appreciated!
Edit: I appeared to make a mistake with my screenshots so I have switched to code snippets which is hopefully clearer.
I would suggest checking two possibilities.
A. The active profile coniguration at "~/.dbt/profiles.yml" Snowflake Profile:
and search for 'warehouse:'
my-snowflake-db:
target: dev
outputs:
dev:
type: snowflake
account: [account id]
# User/password auth
user: [username]
password: [password]
role: [user role]
database: [database name]
warehouse: [warehouse name] <<<<<
schema: [dbt schema]
threads: [1 or more]
B. Default warehouse setting for user used for connection ALTER USER:
SHOW USERS;
ALTER USER user_name SET DEFAULT_WAREHOUSE = '<existing_warehouse_name>';
Make sure the Snowflake Role dbt is using has been granted access to the Snowflake Warehouse dbt is using.
show grants on warehouse 'xxxxxxxx'
I followed the normal procedure for connecting with database as it's done in SPRING BOOT but none of my method seems to work. Also I used the below procedure for connects SQL Server and I added SQL Server driver in lib directory but there is no any result. Is there any one who can help me with this please?
dataSource:
pooled: true
jmxExport: true
driverClassName: net.sourceforge.jtds.jdbc.Driver
username: cctz
password: 'cctz*2020'
dialect: org.hibernate.dialect.SQLServer2019Dialect
environments:
development:
dataSource:
dbCreate: update
url: jdbc:jtds:sqlserver://<192.168.200.136>\SQLEXPRESS:1433;databaseName=deptech_db;user=cctz;password=cctz*2020;
test:
dataSource:
dbCreate: update
url: jdbc:jtds:sqlserver://192.168.200.136:1433;DatabaseName=deptech_db
production:
dataSource:
dbCreate: update
url: jdbc:jtds:sqlserver://192.168.200.136:1433;DatabaseName=deptech_db
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
Using Apache Drill,
I successfully created new plugin : mssql
Configuration:
{
type: "jdbc",
driver: "com.microsoft.sqlserver.jdbc.SQLServerDriver",
url: "jdbc:sqlserver://99.99.99.999:1433;databaseName=ABC",
username: "abcuser",
password: "abcuser",
enabled: true
}
But when i try to query again a table I get an error:
select * from mssql.ABC.dbo.TableName
Error:
org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 1, column 15 to line 1, column 19: Table 'mssql.ABC.dbo.TableName' not found SQL Query null [Error Id: feba9fdb-1621-438a-9d7c-304e4252a41f on AA99-9AA9A99.xyz.abc.com:31010]
Even the below command returns no tables:
show tables;
It should be like
select * from mssql.dbo.TableName
I'm running a pretty simple node js app that tracks user hits on a given website. The development version is working just fine writing to a SQL 2012 Enterprise Server, but the production version is getting the following error:
error running query { RequestError: The INSERT permission was denied on the object 'StudentMonitor', database 'LearnOnlineStatus', schema 'dbo'.
at StreamEvents.<anonymous> (C:\Node\MoodleMonitor\node_modules\mssql\lib\msnodesqlv8.js:624:21)
at StreamEvents.g (events.js:286:16)
at emitOne (events.js:96:13)
at StreamEvents.emit (events.js:188:7)
at routeStatementError (C:\Node\MoodleMonitor\node_modules\msnodesqlv8\lib\driverMgr.js:119:20)
at onInvoke (C:\Node\MoodleMonitor\node_modules\msnodesqlv8\lib\driverMgr.js:476:17)
at onQuery (C:\Node\MoodleMonitor\node_modules\msnodesqlv8\lib\driverMgr.js:157:17) name: 'RequestError', message: 'The INSERT permission was denied on the object \'StudentMonitor\', database \'LearnOnlineStatus\', schema \' dbo\'.', code: 'EREQUEST', number: 229, lineNumber: undefined, state: '42000', class: undefined, serverName: undefined, procName: undefined }
It's attempting to execute the following INSERT code:
mssql.getConnection(function(err, client, done) {
for (var i = 0; i < 7; i++) {
client.input('' + (i+1), data[i]);
}
client.query('INSERT INTO [dbo].[StudentMonitor] (time_created, user_id, ip, url, duration, page_title, course_id) VALUES (#1, #2, #3, #4, #5, #6, #7)', function(err, result) {
if(err) {
console.error('error running query', err);
}
// return the client to the connection pool for other requests to reuse
done();
return typeof callback === 'function' ? callback(err, result) : result;
});
});
All credentials listed in configurations are correct, and we've eliminated network issues as a symptom. Trying the insert statement via SQL Manager works fine with those credentials.
What drives me batty is that a select works just fine, and the user account we're using is DBOwner, so should have no issues whatsoever. Checking the table in SQL reveals no weird permissions or triggers, it's just a regular old table.
Currently running on two Windows 2012 (64-bit) R2 servers but the behaviour is the same on both. SQL Native Client 11.0 is installed, and I've added and removed ODBC clients with no impact. Credentials are set via a mssql.conf file that is all correct and confirmed from console logs. Any ideas?
Okay, was using trustedConnection:true with the mssql (lib/mssql.js) stuff, so it was using my credentials rather than the provided ones. Switching this out for false and adding user and password has resolved the issue.
I have some strange issue with querying SQL Server from django.
When I query db twice in single request, I got errors in some cases. Namely when first db query returns big amount of data, we end up with error while querying db second time.
Details:
We're using Microsoft SQL Server backend for Django (https://bitbucket.org/Manfre/django-mssql/src) running on windows.
We want allow user to filter data from some table ("Activity") via form, display it on the website's table and then show related data from another table ("Frames") on map.
class Frames(models.Model):
...
class Activity(models.Model):
frame_from = models.ForeignKey(Frames, ...)
...
The problem is: when we want to filter larger amount of data from Activity (let's say 200rows x 6 colums), we can not make other queries in the same request on table Frames (MARS is turned on in Django settings.py):
result = Aktywnosci.objects.filter(qset1)
is always ok, but
path = Frames.objects.filter(qset2)
when the previous query returned larger amount of data, raises OLE DB Error:
'Microsoft OLE DB Provider for SQL Server' Error: Cannot
create new connection because in manual or distributed transaction mode.
PS. Database settings from settings.py:
# Database for this installation.
DATABASES = {
'default':{
'ENGINE': 'django.db.backends.sqlserver_ado',
'NAME': '***',
'USER': '***',
'PASSWORD': '***',
'HOST': '***',
'PORT': '',
'OPTIONS' : {
'provider': 'SQLOLEDB',
'use_mars': True,
}
}
}
PS2. I came across this issue on the google-code page of djang-mssql: http://code.google.com/p/django-mssql/issues/detail?id=79 - but it seems to be solved in new version of package...
What can I do about it?
Thanks in advance
We got the solution at bitbucket: https://bitbucket.org/Manfre/django-mssql/issue/13/ole-db-provider-for-sql-server-error from Michael Manfre - thanks a lot for this.
The solution is following:
"SQLOLEDB and MARS doesn't work very well and I intend on changing all of the documentation and defaults to assume a native client driver will be used. Try using the native client; "SQLNCLI10" or "SQLNCLI11".
DATABASES = {
'default': {
'ENGINE': 'sqlserver_ado',
'NAME': 'mydb',
'HOST': r'localhost',
'USER': '',
'PASSWORD': '',
'OPTIONS': {
'provider': 'SQLNCLI10',
'extra_params': 'DataTypeCompatibility=80;MARS Connection=True;',
},
}
}
Is "use_mars=True" set up in your "settings.py" file?
http://django-mssql.readthedocs.org/en/latest/settings.html
If this doesn't work, I have a question: is your selection in SQL Server involving tables with triggers on them (transact SQL scripts) - in this case the SQL Server will use a static cursor instead of a firehose one (which is what you need) therefore you will get your error. Try to get rid of the triggers, use some views in SQL Server and select from them instead of tables.