mssql-jdbc

How to pass the values of user defined datatype variable to MS SQL from java using spring jdbc store procedure

帅比萌擦擦* 提交于 2019-12-11 20:01:57
问题 I have the below MS SQL store procedure with the user defined variable ( @Location CREATE PROCEDURE [Organization].[Organization_Insert] ( @OrganizationID NVARCHAR(256), @Location Locationtype ReadOnly ) @Location has following attributes: OrganizationSubID, LocationCode Am using the below java class to invoke the store procedure, class OrganizationInsertProcedure extends StoredProcedure { private final String[] outputParameters = new String[] {OUTPUT}; public PlanActivityInsertProcedure

Ensuring no duplicate records being created in a table per particular column value

只愿长相守 提交于 2019-12-11 19:33:25
问题 Consider the following scenario Suppose there are three fields in a database table ------------------------------------------ PrmiaryKey | Column A | Column B ----------------------------------------- I need to enforce that for values in Column B should have unique values for Column A Example Col B Col A 12 13 (OK) 14 15 (OK) 15 16 (OK) 12 13 (OK) 15 16 (OK) 14 17 (not OK) Since value 14 previously have value 15 under Column B. So it should not have a different value than 15. I need to

Check if Values of one column in another column of different table

亡梦爱人 提交于 2019-12-11 16:32:46
问题 I am new to SQL and struck with this below scenario, can any one of you please help on this. I want to check if the ingredients of a product allowed on production line if so then production line names for the product where it can be produced. Table 1 ProductionLine Allergen BB1 Tree nut BB1 Peanut BB1 Milk BB1 Wheat BB2 Tree nut BB2 Peanut BB2 Milk BB2 soy BB2 Egg Table 2 Product Ingredients P1 Tree nut P1 Peanut P1 Milk P1 soy Here the Product P1 can be produced on BB2 line as all the

SQL Server log in failing from Java DriverManager.getConnection(), working from Python with pymssql.connect()

馋奶兔 提交于 2019-12-11 01:22:27
问题 I'm trying to use DriverManager.getConnection() to connect to a SQL Server db from a Java application, but I keep getting "Login failed for user" errors with it. I've tried using both com.microsoft.sqlserver.jdbc.SQLServerDriver and net.sourceforge.jtds.jdbc.Driver to connect, but both keep hitting the issue. Here's the code I'm using to connect: Class.forName("net.sourceforge.jtds.jdbc.Driver"); conn=DriverManager.getConnection("jdbc:jtds:sqlserver://SERVERADDRESS:1433;DatabaseName=DBNAME

Inserting datetime into a MS SQL table using pyodbc

寵の児 提交于 2019-12-10 12:54:06
问题 I'm trying to insert a datetime value into a MS SQL Server table using pyodbc. If I do it manually, something like: cursor.execute("""insert into currentvalue(value1,currentdatetime) values(55,'2014-06-27 16:42:48.533')""") I have no problem at all, but when I try to do: currenttime = str(datetime.datetime.now()) cursor.execute("""insert into currentvalue(value1,currentdatetime) values(55,"""+ currenttime+")") I got this error: SQL server Incorrect syntax near '07' which i think is the number

hibernate reverse engineering in Netbeans cannot find SQL Server tables

橙三吉。 提交于 2019-12-10 07:00:55
问题 I have a Test SQL Server database installed on my machine. Created a test SQL Server account and two tables were created with this account in TestDb on the default schema. On my Java Web app (simple JSP) I am using Hibernate and configured it to point to the test database. However when I get to create the hibernate.reveng file the wizard does not find/display any available tables. Please see my hibernate config file: <hibernate-configuration> <session-factory> <property name="hibernate

What can cause the SQL Server JDBC error 'The value is not set for the parameter number 0' for an output parameter access?

陌路散爱 提交于 2019-12-09 16:15:59
问题 I have some Java code that accesses SQL Server 2005 which looks something like this: CallableStatement cstmt = ...; ... // Set input parameters cstmt.registerOutParameter(11, Types.INTEGER); cstmt.execute(); int out = cstmt.getInt(11); And the following exception is thrown from the last line: com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 0. at com.microsoft.sqlserver.jdbc.SQLServerException. makeFromDriverError(Unknown Source) at com.microsoft

Laravel with mssql (sqlsrv) not connecting

自作多情 提交于 2019-12-08 00:21:37
问题 I was working on laravel with mysql it was working fine. But I have another scenario now. I need to connect the laravel to ms sql database which is reside on windows server. I have used the following code to connect to the DB app/config/database.php 'default' => 'sqlsrv', 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'IP ADDRESS', 'database' => 'DB Name', 'username' => 'Username', 'password' => 'password', 'prefix' => '', ), but its showing error saying that PDOException could not find

INSERT values in VARBINARY(MAX) column

情到浓时终转凉″ 提交于 2019-12-06 16:37:27
I've table with VARBINARY(MAX) column and I'm tried for inserting value into that table.but I can't. QUERY is INSERT INTO [I_RACEDB].[dbo].[tce_lineno]([lineNo] ,[testCaseName] ,[project]) VALUES (<lineNo, varchar(250),> ,<testCaseName, varbinary(max),>,<project, varchar(100),>) INSERT INTO [I_RACEDB].[dbo].[tce_lineno] ([lineNo],[testCaseName],[project]) VALUES ('44','TestCase_TestCheck01_Mail_Validation','proj001') ERROR is: Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query. How can I insert the values? The error is self

Laravel with mssql (sqlsrv) not connecting

≯℡__Kan透↙ 提交于 2019-12-06 10:08:11
I was working on laravel with mysql it was working fine. But I have another scenario now. I need to connect the laravel to ms sql database which is reside on windows server. I have used the following code to connect to the DB app/config/database.php 'default' => 'sqlsrv', 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'IP ADDRESS', 'database' => 'DB Name', 'username' => 'Username', 'password' => 'password', 'prefix' => '', ), but its showing error saying that PDOException could not find driver So please can any one help me to solve this ? Thank you Are you using homestead? I had that exact