I'm in SQLSERVER (2008 R2 EXPRESS) administrators list. I'm in administrator role on my machine. And I can manually connect to SQLSERVER (via Management Tools) using ServerName (in my case it's S-PROG-T\SQLEXPRESS). During installation I decided to use only Windows Authentication mode. I can't connect to SS.
Error message is: Login failed for user S-PROG-T\admin. Cannot open database 'ProjectDB' requested by the login.
I'm using the following configuration for NHibernate:
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="dialect">
NHibernate.Dialect.MsSql2008Dialect
</property>
<property name="connection.driver_class">
NHibernate.Driver.Sql2008ClientDriver
</property>
<property name="connection.connection_string">
Data Source=S-PROG-T\SQLEXPRESS;Initial Catalog=ProjectDB;Integrated Security=SSPI
</property>
<property name="show_sql">
true
</property>
<mapping resource="Project.Domain.Model.Entities.Mappings.Vehicle.hbm.xml" assembly="Project.Domain" />
</session-factory>
And I've tried to connect using .\SQLEXPRESS data source. Inbound rules don't restrict SSMS.
What's wrong?
Thanks!
EDIT: Unit tests
Everything (nhibernate configuration, and schema export trial) starts inside my unit test (I don't know if this matters).
[TestFixture]
public class VehicleFixture
{
[Test]
public void TestSchemaExport()
{
new SchemaExport(new Configuration().Configure()).Execute(false, true, false);
}
}
EDIT: Log information
I discovered the next information inside a log (path: %ProgramFiles%\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Log\):
Error: 18456; State: 38.
Login failed for user ‘S-PROG-T\Admin’.
Reason: Failed to open the explicitly specified database.
According to the article: http://sql-articles.com/articles/troubleshooting/troubleshooting-login-failed-error-18456/ database doesn’t exist or login doesn’t have access to the database.
I'm totally confused. Should I have created the database (manually) before I tried to export schema (sorry if the question is silly)?
EDIT: Using Mixed Authentication mode
I've set Mixed mode Authentication and created new login with serveradmin & sysadmin roles. But still the error message is the same, except for user name. Again I can manually do the same thing (connect and create db) with the login and its password.
Ok. I misunderstood the whole process. Everything's ok with Authentication and rather with connection strings. I just thought that schema export stands for database automated-creation and then schema export. So I created a DB and successfully exported a schema.
Can you connect with NHibernate if you change database to 'master'?
Is ProjectDB database user S-PROG-T\admin mapped to server login that you use to connect using management tools?
Can you connect to database using user/password combination in property name="connection.connection_string" instead of integrated security = SSPI?
EDIT You write that you created new login. But still - login is something used for SERVER authentication. You must have database user in ProjectDB mapped to server login to access the database.
Look at this thread: TSQL to Map User to Database
or read here: http://www.nerdymusings.com/LPMArticle.asp?ID=41
The website will not be using the same identity, therefore will not be an administrator. You can either define a specific identity and set your ApplicationPool (or your own admin account) to use this. Alternatively, use a login/password rather than integrated security.
Related
I am trying to install dotnetnuke in my localhost but not able to installing dnn and below connection string used in webconfig file.
<add name="SiteSqlServer" connectionString="Server=(local);Database=d1;uid=;pwd=;" providerName="System.Data.SqlClient" />
Below error getting:
I am installing dnn in local host, please help to out this headache installation.
Integrated will attempted to use Windows Authentication for the database connection.
You either need to create a SQL authentication account and choose the "User Defined" option, or you need to add the user for your app pool to SQL to give it access to the D1 database.
I prefer to just use SQL Auth accounts, always ends up easier in my opinion.
I created my scaled application on Openshift server with following command:
rhc app create MyApp jbossews-2.0 -s
Then add Mysql:
rhc cartridge add mysql-5.5 -a MyApp
My application using Struts2, Spring & Hibernate. I configured the datasource as follow:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/MysqlDS"/>
</bean>
The JNDI "MysqlDS" is defined in .openshift\config\context.xml with the connection url:
url="jdbc:mysql://5344d4de4382ec43c9000090-myapp.rhcloud.com:37941/mydb"
The problem is my scale app can not establish the connection to Mysql with an error:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect
3 times. Giving up.)
I'm sure the username & password to access the database is correct. It seem MySQL on Openshift server doesn't open its port. When I tried to use an external database on freemysqlhosting.net (with open host & port) the application run well. But I just want to use MySQL db on Openshift. Anyone who have experience on this please give me some suggestion. Thanks
Make sure that you restarted your application after adding the mysql cartridge, sometimes the environment variables don't show up correctly until you restart. Also try to ssh to your gear and see if you can use the "mysql" command to connect to your mysql database directly.
If you left the .openshift/config/context.xml unchanged, the JNDI name fore the MySQL datasource is actually jdbc/MySQLDS and not jdbc/MysqlDS.
This was changed some time ago.
The documentation here http://openshift.github.io/documentation/oo_cartridge_guide.html#tomcat-cartridge-integrations is unfortunately not correct.
I successfully completed the DataNucleus Tutorial for JDO using RDBMS with a local MySQL instance on my Ubuntu 13.10 machine.
While attempting to get the same working on a Google CloudSQL instance, I ran into some problems.
To make the switch, I replaced the following:
<property name="javax.jdo.option.ConnectionURL" value="jdbc:mysql://127.0.0.1/nucleus?useServerPrepStmts=false"/>
<property name="javax.jdo.option.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
... with the following:
<property name="javax.jdo.option.ConnectionURL" value="jdbc:google:mysql://<my-project>:nucleus/nucleus?useServerPrepStmts=false"/>
<property name="javax.jdo.option.ConnectionDriverName" value="com.mysql.jdbc.GoogleDriver"/>
I setup the local MySQL and the CloudSQL instances to have the same credentials, so the javax.jdo.option.ConnectionUserName and javax.jdo.option.ConnectionPassword did not need to be changed.
Under the Google Cloud Console Cloud SQL my-project:nucleus MySQL instance, I created a static IP and also whitelisted my development machine's IP address. I verified that I was able to connect natively to it via 'mysql -u root -p -h '.
When I try to run 'mvn datanucleus:schema-create', I get this:
[DEBUG] Exit code: 1
[DEBUG] --------------------
[DEBUG] Standard output from the DataNucleus tool org.datanucleus.store.schema.SchemaTool :
[DEBUG] --------------------
[INFO] DataNucleus SchemaTool : Creation of the schema
An error was encountered creating a PersistenceManagerFactory : Error creating transactional connection factory - please consult the log for more information.
If I replace the connection settings with the following then it works the same as with the local MySQL instance:
<property name="javax.jdo.option.ConnectionURL" value="jdbc:mysql://<Cloud SQL IP>/nucleus?useServerPrepStmts=false"/>
<property name="javax.jdo.option.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
So, I've worked around the problem, but why didn't this work with the GoogleDriver? I don't know anything about the black magic that's going on inside that driver, but I'm curious if there was a way to make that work, and whether there's a reason I should use the GoogleDriver at all.
Now that you can use the stock MySQL driver with Cloud SQL, you should use that instead of the older GoogleDriver.
See http://googlecloudplatform.blogspot.com/2013/10/google-cloud-sql-now-accessible-from-any-application-anywhere.html
Hope this helps,
Rob
The special Google JDBC driver is for use from Google App Engine applications only. When using it, the CloudSQL instance does not require a static public IP address, which is a billable feature of CloudSQL.
This all becomes obvious after reading the Google CloudSQL docs here and here.
I've developed an application using JSP, Spring Security, MySql. I deployed it on Cloudfoundry. But just war file and I binded mysql service. But I also have to configure MySQL database that consists of two tables, new user and it all in my own database. While i tested my application on localhost i prepared the database running manual scripts in MySQL command window.
Question: How can I make the same configurations in CloudFoundry? can I the same way run all commands and scripts manually or export the database somehow? if yes, how to do this. And what to write here now instead of localhost?
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/security_filter" />
thank you
Caldecott (vmc tunnel) is the correct way to access your cloudoundry database (for me it works and i am using ruby 1.8): http://docs.cloudfoundry.com/tools/vmc/caldecott.html
If that does not work for you you will have to do something manually (much harder):
Create a sample jsp/servlet application that connects to a mysql database (retrieving connection string, username and password as input from user). Then it will just run the sql statement against the database ( sql statement will be also input from user)
Bundle this application in your war
Now you have to retrieve database connection string/username and password. You can retrieve them from the enviromental variable VCAP_SERVICES. Just log log it in a startup listener (eg ServletContextListener)
Deploy your war and get logs from server (vmc logs ApplicationName). Get connection string, username and password
Logon to your application and use your database application to access the database using the db info you collected in the previous step
Just note that this is very dangerous approach. Just be sure to secure this database application or after the initial import remove it from your war and redeploy the application
As a final note you can check if such a database console application already exists so that you dont have to create your own (for example grails has a nice application for this http://grails.org/plugin/dbconsole. Maybe something exists for jsp/servlets)
Hope it helps if you have no luck with the ruby problem
You would need to create a mysqldump of your database.
Once you have the mysqldump file, you then use caldecott and perform vmc tunnel to your MySQL service. After you have establish a connection with your MySQL service on Cloud Foundry, you then need to use the mysql command to manually import the mysqldump file into your service.
For how to use vmc tunnel, visit the documentation site at: http://docs.cloudfoundry.com/tools/vmc/caldecott.html
Setup
MVC 3 EF 4.1 Code First - Windows 7 Pro 64 Dev machine, Separate Win 7 Pro for host.
I started with a SQLCE4.0 database, and everything worked fine (database initializer created tables, populated, etc...).
Once I got everything working like I wanted, I scripted out my SqlCe DB, created a real SQL 2008 DB, opened the proper ports and enabled TCP connections.
Problem
IF I Change my connection string to point to my intranet server\instance name, with a user I created for this app specifically, it works perfectly running from my dev machine.
IF I publish the app to the server (the web server and sql server are the same), and I try to login to the website (aka access the db), then I get:
CREATE DATABASE permission denied in database 'master'.
I commented out the DBInitializer setup so nothing should be created upon a db hit. The tables are there already.
If I do Database.SetInitializer(null); then I get a different login error:
I don't remember exactly but it was something to the affect of LOGIN FAILED FOR IIS APPPOOL\ApplicationPoolIdentity
So I changed the Identity to NETWORK SERVICE and even tried LOCAL SERVICE, both giving the same login failed error.
I tried following this post who says add a SQL user named 'IIS APPPOOL\MyApplicationName'. SQL Wont let me do that as it has invalid characters ... go figure.
Why does it work perfectly over the network accessing the DB from my dev machine, but when I publish to THE SAME machine that hosts the sql and the site, I get permission denied or login failed errors? I've scoured the net and tried different things.
EDIT: Here are my connection strings:
<add name="AntripContext" connectionString="Data Source=|DataDirectory|AntripWeb.sdf" providerName="System.Data.SqlServerCe.4.0" />
<!--<add name="AntripSQL" connectionString="Data Source=.\sqlexpress;Initial Catalog=Antrip;User Id=myuser;Password=mypassword;" providerName="System.Data.SqlClient" />-->
<add name="AntripWebEntities" connectionString="metadata=res://*/DAL.AntripEntities.csdl|res://*/DAL.AntripEntities.ssdl|res://*/DAL.AntripEntities.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="Data Source=|DataDirectory|\AntripWeb.sdf"" providerName="System.Data.EntityClient" />
<!--<add name="AntripWebEntities" connectionString="metadata=res://*/DAL.AntripEntities.csdl|res://*/DAL.AntripEntities.ssdl|res://*/DAL.AntripEntities.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\sqlexpress;Initial Catalog=Antrip;User Id=myuser;Password=mypassword;"" providerName="System.Data.EntityClient" />-->
Note: The commented out connection strings are the ones that use the sql 2008 database (that break my published app).
It sounds to me as if your connection string has Integrated Security=true so that you are connecting to SQL as the user you specify, rather than the SQL user you think you are using?
But beware, its still trying to create a database: you need to swap the IDatabaseInitializer - I guess it will look for a DB named the same as the entitys to be careful!